add ssl_no_verify option to all http exports, RT#29298
[freeside.git] / FS / FS / Misc / DateTime.pm
index a32c15a..1c023f9 100644 (file)
@@ -3,11 +3,12 @@ package FS::Misc::DateTime;
 use base qw( Exporter );
 use vars qw( @EXPORT_OK );
 use Carp;
+use Time::Local;
 use Date::Parse;
 use DateTime::Format::Natural;
 use FS::Conf;
 
-@EXPORT_OK = qw( parse_datetime );
+@EXPORT_OK = qw( parse_datetime day_end );
 
 =head1 NAME
 
@@ -47,7 +48,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);
@@ -55,6 +56,21 @@ sub parse_datetime {
   
 }
 
+=item day_end TIME
+
+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 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+        localtime($time);
+    timelocal(59,59,23,$mday,$mon,$year);
+}
+
 =back
 
 =head1 BUGS