X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc%2FDateTime.pm;h=e36f3a95a90921d35d47137f59ba2e349c122c8e;hb=aed8ec35ccb9cdeb7ea0cb6ff2946f9d83d582f6;hp=a32c15aea5dee4ff0ddcf9cbc4f0fb84d1dd938d;hpb=b5c4237a34aef94976bc343c8d9e138664fc3984;p=freeside.git diff --git a/FS/FS/Misc/DateTime.pm b/FS/FS/Misc/DateTime.pm index a32c15aea..e36f3a95a 100644 --- a/FS/FS/Misc/DateTime.pm +++ b/FS/FS/Misc/DateTime.pm @@ -2,12 +2,13 @@ package FS::Misc::DateTime; use base qw( Exporter ); use vars qw( @EXPORT_OK ); +use POSIX; use Carp; use Date::Parse; use DateTime::Format::Natural; use FS::Conf; -@EXPORT_OK = qw( parse_datetime ); +@EXPORT_OK = qw( parse_datetime day_end ); =head1 NAME @@ -55,6 +56,28 @@ sub parse_datetime { } +=item day_end TIME + +If the next-bill-ignore-time configuration setting is turned off, just +returns the passed-in value. + +If the next-bill-ignore-time configuration setting is turned on, parses TIME +as an integer UNIX timestamp and returns a new timestamp with the same date but +23:59:59 for the time. + +=cut + +sub day_end { + my $time = shift; + + my $conf = new FS::Conf; + return $time unless $conf->exists('next-bill-ignore-time'); + + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = + localtime($time); + mktime(59,59,23,$mday,$mon,$year,$wday,$yday,$isdst); +} + =back =head1 BUGS