File: [local] / RT / Invoicing / lib / RTI / Util.pm (download)
Revision 1.1, Sat Dec 31 02:14:48 2011 UTC (12 years, 6 months ago) by andrew
Branch: MAIN
Made invdate, start and end DateTime objects
Made RTI::State expand the above
Made RTI::State better at saving
Moved utility functions to RTI::Util
|
package RTI::Util;
use strict;
use warnings;
use base 'Exporter';
use 5.010;
use Carp;
use DateTime;
our @EXPORT_OK = qw/ ymd_to_DateTime /;
sub ymd_to_DateTime {
my ($ymd) = @_;
return unless $ymd;
my ( $date, $time ) = split /[\sT]/, $ymd;
my ( $year, $month, $day ) = split '-', $date;
my ( $hour, $minute, $second ) = split ':', $time if $time;
return DateTime->new(
year => $year,
month => $month,
day => $day,
hour => $hour || 0,
minute => $minute || 0,
second => $second || 0,
time_zone => 'local',
);
}