I'd say if the documentation mentions it, but doesn't say why, then we're not 
gonna be able to do much better for you as far as "why" goes.

http://pytz.sourceforge.net/

"Unfortunately using the tzinfo argument of the standard datetime constructors 
"does not work" with pytz for many timezones."

But it looks like they suggest something along the lines of...

timezone('Europe/Amsterdam').localize(datetime(2018, 12, 17, 11, 31, 26))


>From the examples on http://pytz.sourceforge.net/#problems-with-localtime ...

>>> eastern = timezone('US/Eastern')
>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'
>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)
>>> est_dt = eastern.localize(loc_dt, is_dst=True)
>>> edt_dt = eastern.localize(loc_dt, is_dst=False)
>>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt))
2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500


Browse through their examples and see if you can find something similar that 
works for you.


-----Original Message-----
From: Python-list 
[mailto:python-list-bounces+david.raymond=tomtom....@python.org] On Behalf Of 
Jaap van Wingerde
Sent: Wednesday, February 06, 2019 9:27 AM
To: python-list@python.org
Subject: timezones

I made a small script to practise with timezones:

#!/usr/bin/env python3
# -*- coding: utf_8 -*-
from datetime import datetime, timedelta
from pytz import timezone
import pytz
amsterdam_datetime = datetime(2018, 12, 17, 11, 31, 26,
tzinfo=timezone('Europe/Amsterdam'))
print(amsterdam_datetime)
utc_datetime = amsterdam_datetime.astimezone(pytz.utc)
print(utc_datetime)
amsterdam_datetime = datetime(2018, 6, 17, 11, 31, 26,
tzinfo=timezone('Europe/Amsterdam'))
print(amsterdam_datetime)
utc_datetime = amsterdam_datetime.astimezone(pytz.utc)
print(utc_datetime)

The output of the script is:
2018-12-17 11:31:26+00:20
2018-12-17 11:11:26+00:00
2018-06-17 11:31:26+00:20
2018-06-17 11:11:26+00:00

I respected:
2018-12-17 11:31:26+01:00
2018-12-17 10:31:26+00:00
2018-06-17 11:31:26+02:00
2018-06-17 09:31:26+00:00

I need this functionality for adjusting wrong timestamps in Android
JPG-images as the 'Exif.GPSInfo.GPSTimeStamp' and
'Exif.GPSInfo.GPSDateStamp' are missing.

Why I get this unrespected results?

Kind regards,
Jaap.


-- 

Jaap van Wingerde
e-mail: 1234567...@vanwingerde.nl

-- 
https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to