[BACK]Return to Util.pm CVS log [TXT][DIR] Up to [local] / RT / Invoicing / lib / RTI

Annotation of RT/Invoicing/lib/RTI/Util.pm, Revision 1.2

1.1       andrew      1: package RTI::Util;
                      2: use strict;
                      3: use warnings;
                      4:
                      5: use base 'Exporter';
                      6: use 5.010;
                      7: use Carp;
                      8: use DateTime;
                      9:
1.2     ! andrew     10: our @EXPORT_OK = qw/ round ymd_to_DateTime /;
        !            11:
        !            12: sub round {
        !            13:     my ($amount) = @_;
        !            14:
        !            15:     #$amount =~ s/\.\d\d\K.*$//;
        !            16:     #return $amount;
        !            17:     return sprintf "%.02f", $amount;
        !            18: }
1.1       andrew     19:
                     20: sub ymd_to_DateTime {
                     21:     my ($ymd) = @_;
                     22:
                     23:     return unless $ymd;
                     24:
                     25:     my ( $date, $time ) = split /[\sT]/, $ymd;
                     26:     my ( $year, $month, $day ) = split '-', $date;
                     27:     my ( $hour, $minute, $second ) = split ':', $time if $time;
                     28:
                     29:     return DateTime->new(
                     30:         year      => $year,
                     31:         month     => $month,
                     32:         day       => $day,
                     33:         hour      => $hour || 0,
                     34:         minute    => $minute || 0,
                     35:         second    => $second || 0,
                     36:         time_zone => 'local',
                     37:     );
                     38: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>