I find time fascinating, so happy to help : ).
Thanks for that pastebin. That’s really helpful.
We can see the problem is with the following call:
$calendar->days_between( dt_from_string($data->{date_due}),$date_to_run );
If I follow correctly, $date_to_run should be the time when you run the script in America/Santiago time.
$data->{date_due} will be from the database… probably the issues table I think… and I think that’s looking OK, since the following line appears in the debugger:
Koha::Calendar::days_between('Koha::Calendar=HASH(0x65dcf80)', 'DateTime=HASH(0x6507b38)', 'DateTime=HASH(0x64e7848)')
We’d have an error earlier if those dates were the ones causing problems… so I think they’re OK since they’ve been created into objects as evidenced above.
However… 'DateTime=HASH(0x6507b38)' is cloned in Koha::Calendar::days_between() and has Koha::Calendar::is_holiday() run on it…
--
I have an urgent matter now, but that’s part of the way there. I’m thinking the problem is with the “date_due” from one of the overdue items! Possibly something from September if the debug message is correct…
David Cook
Systems Librarian
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Office: 02 9212 0899
Direct: 02 8005 0595
From: Larry Letelier [mailto:larry@opengeek.cl]
Sent: Thursday, 28 April 2016 1:05 PM
To: David Cook <dcook@prosentient.com.au>
Cc: koha-devel@lists.koha-community.org
Subject: Re: [Koha-devel] Invalid local time for date in time zone: America/Santiago
Hi David,
Thanks for you reply,
yes your are right, Chile abolished dst, we have a minister with many earthquakes in him head.
So,
Here is the “perl -d overdue_notices.pl -t" using "n":
If i run again :
perl overdue_notices.pl -t
Invalid local time for date in time zone: America/Santiago
Thanks in advance guys,
-- Larry Letelier N.
F: +56 2 3205 2737
F: +56 9 7589 6842
![]()
2016-04-27 23:53 GMT-03:00 David Cook <dcook@prosentient.com.au>:
I’ve seen this happen on other Perl projects during daylight savings time changes.
For instance, try the following Perl code:
use DateTime;
my $dt = DateTime->new(
year => 2015,
month => 10,
day => 4,
hour => 2,
minute => 0,
second => 0,
time_zone => 'Australia/Sydney',
);
You’ll get the message:
“Invalid local time for date in time zone: Australia/Sydney”
If I recall correctly, it’s because 4 October 2015 2:00am Australia/Sydney didn’t exist. When that time was reached, the clock actually skipped forward, and it became 4 October 2015 3:00am Australia/Sydney. In effect, local time went from 1:59:59 to 3:00:00. 2:00:00 through 2:59:59 never existed. Fascinating, no?
Wikipedia says that Chile stopped observing DST in 2015: https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_Americas#Chile. However, I’m guessing that perhaps your server/the Perl module doesn’t know that?
“Chile currently observes Daylight Saving Time (DST). Instead of turning the clocks back one hour on Sunday, April 26, 2015 as previously planned, the Chilean Government has decided to make no further changes to the clock in future years.” (http://www.timeanddate.com/news/time/chile-abolishes-dst-2015.html).
Hmm… I don’t know what date is the problem…
Could you run “perl -d overdue_notices.pl -t" again, but use “n” instead of “c”? That way, you’ll be able to see what exact call is generating this error.
I’m guessing it might be one of the lines:
my $today = DateTime->now(time_zone => C4::Context->tz );
But that’s just a guess. What happens if you try running your overdues again? You might have had the misfortune of the overdues just running at the wrong time on the wrong day.
Curious to hear how you go!
David Cook
Systems Librarian
Prosentient Systems
72/330 Wattle St
Ultimo, NSW 2007
Office: 02 9212 0899
Direct: 02 8005 0595
From: koha-devel-bounces@lists.koha-community.org [mailto:koha-devel-bounces@lists.koha-community.org] On Behalf Of Larry Letelier
Sent: Wednesday, 27 April 2016 3:09 PM
To: koha-devel@lists.koha-community.org
Subject: [Koha-devel] Invalid local time for date in time zone: America/Santiago
Hi people,
We have a 'little' issue with the overdue aka notifications process.
# pwd
/usr/share/koha/bin/cronjobs
# ./overdue_notices.pl -t
Invalid local time for date in time zone: America/Santiago
perl -d overdue_notices.pl -t
Loading DB routines from perl5db.pl version 1.33
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(overdue_notices.pl:278): my $dbh = C4::Context->dbh();
DB<1> c
Invalid local time for date in time zone: America/Santiago
at /usr/share/perl5/DateTime/TimeZone.pm line 198
DateTime::TimeZone::_span_for_datetime('DateTime::TimeZone::America::Santiago=HASH(0x60cfce8)', 'local', 'DateTime=HASH(0x617e938)') called at /usr/share/perl5/DateTime/TimeZone.pm line 157
DateTime::TimeZone::offset_for_local_datetime('DateTime::TimeZone::America::Santiago=HASH(0x60cfce8)', 'DateTime=HASH(0x617e938)') called at /usr/lib/perl5/DateTime.pm line 930
DateTime::_offset_for_local_datetime('DateTime=HASH(0x617e938)') called at /usr/lib/perl5/DateTime.pm line 375
DateTime::_calc_utc_rd('DateTime=HASH(0x617e938)') called at /usr/lib/perl5/DateTime.pm line 263
DateTime::_new('DateTime', 'hour', 20, 'second', 0, 'month', 9, 'locale', 'DateTime::Locale::en_US=HASH(0x1e7eac8)', ...) called at /usr/lib/perl5/DateTime.pm line 299
DateTime::_new_from_self('DateTime=HASH(0x6183808)', 'hour', 0, 'minute', 0, 'second', 0, 'month', 9, ...) called at /usr/lib/perl5/DateTime.pm line 1933
DateTime::truncate(undef, 'to', 'day') called at /usr/share/koha/lib/Koha/Calendar.pm line 214
Koha::Calendar::is_holiday('Koha::Calendar=HASH(0x619bc20)', 'DateTime=HASH(0x6192ad0)') called at /usr/share/koha/lib/Koha/Calendar.pm line 290
Koha::Calendar::days_between('Koha::Calendar=HASH(0x619bc20)', 'DateTime=HASH(0x61a5b90)', 'DateTime=HASH(0x60a7ce0)') called at overdue_notices.pl line 538
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q
This is a Koha 3.2008000
In MySQL and in enviroment, tzdata, TZ='America/Santiago' is set.
Any idea with this ?
Thanks for read this,
-Larry