Bug 4364 - SIP Checkout dates incorrect
authorColin Campbell <colin.campbell@ptfs-europe.com>
Thu, 1 Apr 2010 20:02:14 +0000 (21:02 +0100)
committerGalen Charlton <gmcharlt@gmail.com>
Wed, 7 Apr 2010 10:56:27 +0000 (06:56 -0400)
Change timestamp routine to do the right thing when passed an iso date
Otherwise was generating an epoch date of 0

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
C4/SIP/Sip.pm

index f176516..c76959b 100644 (file)
@@ -9,6 +9,7 @@ use warnings;
 use English;
 use Exporter;
 
+use DateTime;
 use Sys::Syslog qw(syslog);
 use POSIX qw(strftime);
 use Socket qw(:crlf);
@@ -49,6 +50,13 @@ our $last_response = '';
 
 sub timestamp {
     my $time = $_[0] || time();
+    if ($time=~m/^(\d{4})\-(\d{2})\-(\d{2})/) {
+        my $dt = DateTime->new(
+            year  => $1,
+            month => $2,
+            day   => $3);
+        $time = $dt->epoch();
+    }
     return strftime(SIP_DATETIME, localtime($time));
 }