You are here: Foswiki>Tasks Web>Item1547 (19 Jan 2024, MarcSCHAEFER)Edit Attach

Item1547: CalendarPlugin wishlist: ISO 8661 dates as input

pencil
Priority: Enhancement
Current State: Needs Developer
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: CalendarPlugin
Branches:
Reported By: MarcSCHAEFER
Waiting For:
Last Change By: MarcSCHAEFER
I find it handy to be able to have ISO 8661 dates (at least YYYY-MM-DD) in CalendarPlugin.

Patch for Foswiki 2.1.8:
--- Foswiki-2.1.8/lib/Foswiki/Plugins/CalendarPlugin/Core.pm.orig       2024-01-17 21:57:45.552355592 +0100
+++ Foswiki-2.1.8/lib/Foswiki/Plugins/CalendarPlugin/Core.pm    2024-01-17 22:14:24.717738963 +0100
@@ -52,6 +52,8 @@
 my $periodic_rx         = "E([0-9]+)\\s+$full_date_rx";
 my $numdaymon_rx        = "([0-9L])\\s+($wdays_rx)\\s+($months_rx)";

+my $iso_date_rx = "($years_rx)-([0-9][0-9])-([0-9][0-9])";
+
 #TODO: really should replace this naive regex code with a parser that can build up dates using the &dash's as delimiters.
 #or, as a slightly lazyer option, remove the need for an 'ordered' processing by using the &dash..
 #accepted date and interval definitions
@@ -82,6 +84,10 @@
         pattern => $full_date_rx,
         keys    => [qw(name dd mm yy xs xcstr descr )]
     },
+    'ISO-8861 dates' => {
+        pattern => $iso_date_rx,
+        keys    => [qw(name yy mm dd xs xcstr descr )]
+    },
     'anniversary dates' => {
         pattern => "$anniversary_date_rx",
         keys    => [qw(name dd mm yy xs xcstr descr )]
@@ -732,6 +738,17 @@
                   if $@ && (TRACE);
             }

+            if ($d->{name} eq 'ISO-8861 dates') {
+                eval {
+                    if ($d->{yy} == $y && $d->{mm} == $m )
+                    {
+                        _highlightDay($cal, $d->{dd} + 0, $d->{descr}, %options);
+                    }
+                };
+                Foswiki::Func::writeWarning( PLUGINNAME . ": $@ " )
+                  if $@ && (TRACE);
+            }
+
             # collect all anniversary dates
             if ( $d->{name} eq 'anniversary dates' ) {
                 eval {
@@ -1370,6 +1387,7 @@
         'intervals with year',
         'intervals without year',
         'dates with year',
+        'ISO-8861 dates',
         'anniversary dates',
         'dates without year',
         'monthly repeaters',

Much older patch as reference:
--- ./lib/Foswiki/Plugins/CalendarPlugin.pm-2009-04-29  2009-04-29 18:56:18.000000000 +0000
+++ ./lib/Foswiki/Plugins/CalendarPlugin.pm     2009-04-29 18:58:31.000000000 +0000
@@ -556,6 +556,7 @@
        local $weekly_rx = "E\\s+($wdays_rx)";
        local $periodic_rx = "E([0-9]+)\\s+$full_date_rx";
        local $numdaymon_rx = "([0-9L])\\s+($wdays_rx)\\s+($months_rx)";
+        local $iso_8601 = "\\s*(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)\\s*";
 
        # Keep only bullet lines from the text. Note that this is done
        # inside the loop because as each pattern is matched by
@@ -566,6 +567,22 @@
 
        my @bullets = grep { /^\s+\*/ } split( /[\n\r]+/, $text );
 
+        # collect standard dates (ISO-8601)
+        @days = fetchDays($iso_8601, \@bullets);
+        foreach $d (@days) {
+           ($yy, $mm, $dd, $xs, $xcstr, $descr) = split(/\|/, $d);
+            eval {
+                # hack
+                $mm += 0;
+                $dd += 0;
+ 
+                if ($yy == $y && $mm == $m) {
+                    &highlightDay( $cal, $dd, $descr, %options);
+                }
+            };
+            &Foswiki::Func::writeWarning( "$pluginName: $@ " ) if $@ && $debug;
+        }
+  
        # collect all date intervals with year
        @days = fetchDays( "$full_date_rx\\s+-\\s+$full_date_rx", \@bullets );
        $multidaycounter = 0;

ItemTemplate edit

Summary CalendarPlugin wishlist: ISO 8661 dates as input
ReportedBy MarcSCHAEFER
Codebase 2.1.8, 1.0.4
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component CalendarPlugin
Priority Enhancement
CurrentState Needs Developer
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release02x01Checkins
Release02x00Checkins
Release01x01Checkins
Topic revision: r4 - 19 Jan 2024, MarcSCHAEFER
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy