2

While troubleshooting a separate issue, I found that in pytz the timezone 'Asia/Jakarta' is UTC offset by 7h 7m

Why is this? By everything i can find, the offset for Asia/Jakarta should only be 7h

import pytz
x = pytz.timezone('Asia/Jakarta')
x._utcoffset
# datetime.timedelta(0, 25620)

25620s = 427 min or 7 hr and 7 min

Am I missing something?

martineau
  • 119,623
  • 25
  • 170
  • 301
w--
  • 6,427
  • 12
  • 54
  • 92
  • `x.utcoffset(dt.now())` gives me `datetime.timedelta(0, 25200)` – deadvoid Nov 03 '18 at 14:42
  • You're just getting the first entry in the tz record. Apply it to a particular date and time and you'll get the expected result. – Matt Johnson-Pint Nov 03 '18 at 23:14
  • @MattJohnson are you able to elaborate more on that? don't understand what you mean by `just getting the first entry in the tz record`. part of the reason I went down this path is because when i apply that timezone to a datetime object, i can see the offset is 7h7m instead of just just 7h. – w-- Nov 05 '18 at 03:47
  • 2
    Are you using the `localize` function like stated in the docs? Or are you just replacing `tzinfo`? Lots of folks fall into that trap. It's been asked and answered a few times around here before. [Here's one example](https://stackoverflow.com/q/11473721/634824). – Matt Johnson-Pint Nov 05 '18 at 05:25
  • @MattJohnson oh wow. TIL. i was just replacing tzinfo. Thanks for the comment. If you submit it as an answer i'm happy to accept it. – w-- Nov 07 '18 at 08:38
  • also, i'm looking through the docs. http://pytz.sourceforge.net/#localized-times-and-date-arithmetic there isn't much here in the way of explanation. is there another set of docs i should be looking at? – w-- Nov 07 '18 at 09:22
  • Personally, I prefer [dateutil](https://pypi.org/project/python-dateutil/). :) – Matt Johnson-Pint Nov 07 '18 at 15:18

1 Answers1

0

so i just saw this link
http://pytz.sourceforge.net/#issues-limitations

which lead me to
http://www.iana.org/time-zones.

downloading the data and inspecting i found this info in asia file

>     # From Paul Eggert (2014-09-06):
>     # The 1876 Report of the Secretary of the [US] Navy, p 306 says that Batavia
>     # civil time was 7:07:12.5; round to even for Jakarta.

ok then.....

w--
  • 6,427
  • 12
  • 54
  • 92