X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc%2FDateTime.pm;h=08cf9a9456c3522fc57fe95dfec7262bb7af82c4;hb=9faa6b1e007238ea1d953dfffa5c9089253b420c;hp=99ff409e67eea6ece05a561770e4c225d221c6cf;hpb=6897aea6913f9f8ab39803e8f8e06c1adefcd916;p=freeside.git diff --git a/FS/FS/Misc/DateTime.pm b/FS/FS/Misc/DateTime.pm index 99ff409e6..08cf9a945 100644 --- a/FS/FS/Misc/DateTime.pm +++ b/FS/FS/Misc/DateTime.pm @@ -2,13 +2,14 @@ package FS::Misc::DateTime; use base qw( Exporter ); use vars qw( @EXPORT_OK ); -use POSIX; use Carp; +use Time::Local; use Date::Parse; use DateTime::Format::Natural; +use Date::Format; use FS::Conf; -@EXPORT_OK = qw( parse_datetime day_end ); +@EXPORT_OK = qw( parse_datetime day_end iso8601 ); =head1 NAME @@ -49,7 +50,7 @@ sub parse_datetime { #carp "WARNING: can't parse date: ". $parser->error; #return ''; #huh, very common, we still need the "partially" (fully enough for our purposes) parsed date. - $dt->epoch; + return $dt->epoch; } } else { return str2time($string, $tz); @@ -65,11 +66,22 @@ same date but 23:59:59 for the time. =cut sub day_end { - my $time = shift; + my $time = shift; + + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = + localtime($time); + timelocal(59,59,23,$mday,$mon,$year); +} + +=item iso8601 TIME + +Parses time as an integer UNIX timestamp and returns the ISO 8601 formatted +date and time. + +=cut - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = - localtime($time); - mktime(59,59,23,$mday,$mon,$year,$wday,$yday,$isdst); +sub iso8601 { + time2str('%Y-%m-%dT%T', shift); } =back