From: Bill Erickson Date: Mon, 16 Nov 2015 19:48:23 +0000 (-0500) Subject: LP#1516757: ensure that SIP2 returns DOB correctly X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=86c5da0b4da0cf20141ef774536a7f1723f3592b;p=evergreen%2Ftadl.git LP#1516757: ensure that SIP2 returns DOB correctly 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. To test ------- [1] Fire up a SIP client of some sort and retrieve a patron record; verify that the patron's date of birth is correct, and not offset by one day. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm index bd11e1978e..cf98f33e62 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP.pm @@ -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; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm index 16f2563295..130d9bfcfa 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/SIP/Patron.pm @@ -299,7 +299,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; }