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
_______________________________________________
Remind-fans mailing list
[email protected]
http://lists.roaringpenguin.com/cgi-bin/mailman/listinfo/remind-fans
Remind is at http://www.roaringpenguin.com/products/remind