Skip to content

Commit

Permalink
Use a different package for parsing dates, handles time zones correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Mar 14, 2011
1 parent 71f7ffe commit daf6157
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions WTPA.pm
Expand Up @@ -10,10 +10,10 @@ use JSON;
use DateTime; use DateTime;
use Net::PingFM; use Net::PingFM;
use LWP::Simple; use LWP::Simple;
use Time::ParseDate;
use WWW::Shorten::Bitly; use WWW::Shorten::Bitly;
use Net::Google::Calendar; use Net::Google::Calendar;
use Config::Abstract::Ini; use Config::Abstract::Ini;
use DateTime::Format::Natural;
use base 'Exporter'; use base 'Exporter';


our @EXPORT = qw( utilInit calConnect pingConnect events places our @EXPORT = qw( utilInit calConnect pingConnect events places
Expand Down Expand Up @@ -144,7 +144,7 @@ sub addEvent {
my $data = shift; my $data = shift;
my $start; my $start;
my $all; my $all;

$data->{when} = parseDate( $data->{when} ); $data->{when} = parseDate( $data->{when} );


# We need to build the dates for the calendar # We need to build the dates for the calendar
Expand Down Expand Up @@ -206,7 +206,7 @@ sub updateEvent {


my $start; my $start;
my $all; my $all;

$data->{when} = parseDate( $data->{when} ); $data->{when} = parseDate( $data->{when} );


# We need to build the dates for the calendar # We need to build the dates for the calendar
Expand Down Expand Up @@ -512,12 +512,13 @@ sub getTime {
sub parseDate { sub parseDate {
my ( $date ) = @_; my ( $date ) = @_;


my $time = parsedate( $date, my $parser = DateTime::Format::Natural->new(
ZONE => $ini->{config}{timezone_short}, time_zone => $ini->{config}{timezone},
PREFER_FUTURE => 1 format => 'mm/dd/yy',
prefer_future => 1
); );


return $time; return $parser->parse_datetime( $date )->epoch();
} }


1; 1;

0 comments on commit daf6157

Please sign in to comment.