hebcal / dotcom

deprecated hebcal.com source code
https://github.com/hebcal/hebcal-web
21 stars 9 forks source link

Midnight hour parameter causes "Software error" #14

Closed lukecarbis closed 9 years ago

lukecarbis commented 9 years ago

When calling the Jewish Calendar REST API at this URL: http://www.hebcal.com/hebcal/?v=1&cfg=json&year=now&month=x&c=on&geo=pos&latitude=37.7873712&longitude=-122.4082288&tzid=Australia/Brisbane

I receive this error:

Software error:

The 'hour' parameter ("24") to DateTime::new did not pass the 'an integer between 0 and 23' callback
 at /usr/lib/perl5/DateTime.pm line 198.
    DateTime::new(undef, 'year', 2015, 'month', 1, 'day', 3, 'hour', 24, ...) called at /home/hebcal/local/share/perl/site_perl/Hebcal.pm line 645
    Hebcal::event_tz_offset(2015, 1, 3, 24, 15, 'Australia/Brisbane') called at /home/hebcal/local/share/perl/site_perl/Hebcal.pm line 702
    Hebcal::event_to_dict('ARRAY(0x16a1ba8)', 1420261201, 'http://www.hebcal.com/hebcal/?v=1;year=2015;geo=pos;latitude=...', 'json', 'CGI=HASH(0x10c5cb8)', 'Australia/Brisbane', 0, 'DBI::db=HASH(0x1bd5e70)', 'DBI::st=HASH(0x1bd6188)', ...) called at /home/hebcal/local/share/perl/site_perl/Hebcal.pm line 805
    Hebcal::events_to_dict('ARRAY(0x18264e8)', 'json', 'CGI=HASH(0x10c5cb8)', 0, 0, 'Australia/Brisbane', 0, 1, 0, ...) called at /var/www/hebcal/index.cgi line 403
    main::json_events() called at /var/www/hebcal/index.cgi line 286

Interestingly, if I change the month parameter to 6 (the current month), the error goes away. However, if I use any other month (1-12 or x), I get the same error page.

mjradwin commented 9 years ago

We'll look into the error.

The root cause of the problem appears to be a geographic position that doesn't correspond to the timezone

Please take a careful look at your lat/long inputs and whether you're passing the correct values. Brisbane is actually at latitude=-27.46794 and longitude=153.02809 and tzid=Australia/Brisbane. The location you're passing (latitude=37.7873712 and longitude=-122.4082288) appears to actually be San Francisco, CA, which really should be tzid=America/Los_Angeles.

lukecarbis commented 9 years ago

Right - that's iOS simulating my location, but using my locale for the timezone. :)

mjradwin commented 9 years ago

OK, we've deployed the change to fix this issue.

Passing nonsense location/timezone into Hebcal will still give nonsense results, but we won't raise a 500 Internal Server Error.

lukecarbis commented 9 years ago

:+1: