[Remind-Fans] Reminder Popups with date and time

Mark Lawrence nomad at null.net
Sun Jun 5 19:23:33 EDT 2011


On Mon Jun 06, 2011 at 10:35:01AM +1200, Mark Lawrence wrote:
> 
> Here is an example that might get you started (warning: completely
> untested code):
> 
>     #!/usr/bin/perl
>     use strict;
>     use warnings;
>     use Date::Remind::Event;
>     use Time::Duration qw/ago/;
> 
>     while ( my $line = <> ) {
>         chomp $line;
>         my $event = Date::Remind::Event->new($line);
>         print ago(time - $event->date->epoch) .': '. $event->body ."\n";
>     }

Woops. I discovered this has an error relating to timezones.  Turns out
the DateTime 'epoch' method returns the UTC epoch (equivalent to the
Perl 'gmtime' fuction, not the 'time' function).  So the second-last
line above should probably be changed to:

         print ago(gmtime - $event->date->epoch) .': '. $event->body ."\n";

Plus in production there should also be some error checking that $line
creates a valid $event.... etc.

Cheers,
Mark.
-- 
Mark Lawrence


More information about the Remind-fans mailing list