See patch provided at
TWiki:Plugins/TablePluginDev by
TWiki:Main/UlrichSpoerlein - 21 Mar 2009
--
TWiki:Main/PeterThoeny - 22 Mar 2009
The patch is slightly incorrect as months run from 0..11 International ISO format is also YYYY-MM-DD.
--- lib/TWiki/Plugins/TablePlugin/Core.pm.orig 2010-04-21 22:39:57.000000000 +0100
+++ lib/TWiki/Plugins/TablePlugin/Core.pm 2010-04-21 23:17:13.000000000 +0100
@@ -533,6 +533,13 @@
$year += 2000 if ( length($year) == 2 );
$date = timegm( 0, 0, 0, $1, $mon2num{$2}, $year - 1900 );
}
+ elsif ( $text =~
+ m|^\s*([0-9]{4})[-/\s]([0-9]{2})[-/\s]([0-9]{2})\s*$| )
+ {
+
+ # ISO "2003-12-31" "2003 12 31" "2003/12/31"
+ $date = timegm( 0, 0, 0, $3, $2 - 1, $1 - 1900 );
+ }
elsif ( $text =~ /^\s*([0-9]+)(\.([0-9]))*(.?)*$/ ) {
# for example for attachment sizes: 1.1 K
--
TWiki:Main.AlexSchuilenburg - 21 Apr 2010
I believe this has been fixed in
Item6414, could you verify if
TWikirev:18412 is correct?
--
TWiki:Main.PeterThoeny - 24 Apr 2010
TWikirev:18412 will work, but IMHO is broken because it will incorrectly accept something like "2010-012-31999999999999999" as a valid date and return christmas day as the value. It lacks the trailing "\s*$", which means it may interpret a bar code as a date. Also there are two totally unnecessary "0?"' matches in the regexp which do nothing to help verify the field as an ISO date (in fact, even with a trailing "\s*$" added, they make the submission of 9999-099-099 possible, as well as single digit month and days, both not permissible by the
ISO 8601 standard. My proposed patch is IMHO a lot more accurate than
TWikirev:18412
--
TWiki:Main.AlexSchuilenburg - 25 Apr 2010
Your proposed patch is more accurate to parse valid ISO dates, but it is not that forgiving. ISO dates are frequently created by humans, especially in TWiki. There is a reason for stripping off the leading 0: Perl interprets a string as an octal number if it starts with a zero. The regex could be tweaked to allow 1 to 2 digits, and to remove a leading 0. As for not anchoring at the end, this is done by design so that date sorting works also if followed by time (albeit without sorting the time). This can be made more robust, such as testing for a non-numeric character at the end of the regex. Untested regex:
m/^\s*([0-9]{4})[-\s\/]0?([0-9]{1,2})[-\s\/]0?([0-9]{1,2})([^0-9]|$)/
--
TWiki:Main.PeterThoeny - 25 Apr 2010