pytz icon indicating copy to clipboard operation
pytz copied to clipboard

'Europe/Dublin' sometimes set to defunct "Dublin Mean Time" timezone

Open further-reading opened this issue 4 years ago • 1 comments

I'm trying to have a script that works with local time in Ireland but it seems that when you set a datetime object to Europe/Dublin and convert to UTC it adds 25 minutes and doesn't offset during DST.

>>> import datetime, pytz
>>> test = datetime.datetime(2018, 3, 1, 8, tzinfo=pytz.timezone('Europe/Dublin'))
>>> test.astimezone(pytz.timezone('UTC')).time()
datetime.time(8, 25)
>>> testDST = datetime.datetime(2018, 3, 30, 8, tzinfo=pytz.timezone('Europe/Dublin'))
>>> testDST.astimezone(pytz.timezone('UTC')).time()
datetime.time(8, 25)

It appears that it might be using Dublin Mean Time, which has been defunct since 1916.

Interestingly, this does not happen when going from UTC to Europe/Dublin.

>>> import datetime, pytz
>>> test = datetime.datetime(2018, 3, 1, 8, tzinfo=pytz.timezone('UTC'))
>>> test.astimezone(pytz.timezone('Europe/Dublin')).time()
datetime.time(8, 0)
>>> testDST = datetime.datetime(2018, 3, 30, 8, tzinfo=pytz.timezone('UTC'))
>>> testDST.astimezone(pytz.timezone('Europe/Dublin')).time()
datetime.time(9, 0)

further-reading avatar Mar 04 '21 12:03 further-reading

I think it might just be how you're using it: TIL: https://stackoverflow.com/questions/24856643/unexpected-results-converting-timezones-in-python

>>> print(pytz.timezone("Europe/Dublin").localize(datetime(2018, 3, 30, 8)))
2018-03-30 08:00:00+01:00

ackerleytng avatar Aug 06 '21 16:08 ackerleytng