22

Possible Duplicate:
Python datetime object show wrong timezone offset

import pytz, datetime

 pytz.timezone("Asia/Calcutta")

prints the following:

< DstTzInfo 'Asia/Calcutta' HMT+5:53:00 STD >

Why it is not 05:30 hrs? I am in time zone America/Los_Angeles.

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
Rajat
  • 1,766
  • 2
  • 21
  • 42

1 Answers1

33

Time zones change over the years. According to http://www.prokerala.com/travel/timezones/Asia/Kolkata?mode=history the original offset for that zone was 5.88888888889 hours, or 5 hours 53 minutes. pytz will use the proper offset and nomenclature once you assign the zone to an actual date.

>>> tz = pytz.timezone("Asia/Calcutta")
>>> tz
<DstTzInfo 'Asia/Calcutta' HMT+5:53:00 STD>
>>> tz.localize(datetime.datetime(1901, 7, 10, 12, 0))
datetime.datetime(1901, 7, 10, 12, 0, tzinfo=<DstTzInfo 'Asia/Calcutta' HMT+5:53:00 STD>)
>>> tz.localize(datetime.datetime(2012, 7, 10, 12, 0))
datetime.datetime(2012, 7, 10, 12, 0, tzinfo=<DstTzInfo 'Asia/Calcutta' IST+5:30:00 STD>)
Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
  • 3
    I believe crazier offsets were much closer to reality: Kolkata longitude: 88.369 deg. Now to get the time offset: (88.369/180)x12=5.89 which approx translates to 5 hrs and 53 minutes. Of course, reality must have made life difficult for everyone, hence rounded offsets now. – tigeronk2 Feb 28 '13 at 06:44
  • 2
    That's not a time offset that was actually enacted by law. It's simply a reflection of [Local Mean Time (LMT)](https://en.wikipedia.org/wiki/Local_mean_time) for the region covered by the zone. You can see this in the tz source data [here](https://github.com/eggert/tz/blob/2017b/asia#L891). – Matt Johnson-Pint Jun 07 '17 at 00:15