LP#1516757 SIP DoB uses local timezone user/berick/lp1516757-sip-dob-tz
authorBill Erickson <berickxx@gmail.com>
Mon, 16 Nov 2015 19:48:23 +0000 (14:48 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 16 Nov 2015 19:48:26 +0000 (14:48 -0500)
Parse dates of birth using the local timezone to ensure that the date in
the database will match what is sent to SIP clients.  Otherwise, the
date will be parsed as UTC and may result in the DoB value being offset
by one day in the SIP response.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/SIP.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm

index bd11e19..cf98f33 100644 (file)
@@ -186,12 +186,19 @@ sub patron_barcode_from_id {
 sub format_date {
     my $class = shift;
     my $date = shift;
-    my $type = shift || 'dob';
+    my $type = shift || '';
 
     return "" unless $date;
 
     my $dt = DateTime::Format::ISO8601->new->
         parse_datetime(OpenSRF::Utils::cleanse_ISO8601($date));
+
+    # actor.usr.dob stores dates without time/timezone, which causes
+    # DateTime to assume the date is stored as UTC.  Tell DateTime
+    # to use the local time zone, instead.
+    # Other dates will have time zones and should be parsed as-is.
+    $dt->set_time_zone('local') if $type eq 'dob';
+
     my @time = localtime($dt->epoch);
 
     my $year   = $time[5]+1900;
index ac4f05c..eebf03e 100644 (file)
@@ -261,7 +261,7 @@ sub home_phone {
 
 sub sip_birthdate {
     my $self = shift;
-    my $dob = OpenILS::SIP->format_date($self->{user}->dob);
+    my $dob = OpenILS::SIP->format_date($self->{user}->dob, 'dob');
     syslog('LOG_DEBUG', "OILS: Patron DOB = $dob");
     return $dob;
 }