"This library only supports two ways of building a localized time. The first is to use the localize() method provided by the pytz library. This is used to localize a naive datetime (datetime with no timezone information):
[...]
The second way of building a localized time is by converting an existing localized time using the standard astimezone() method:
[...]
Unfortunately using the tzinfo argument of the standard datetime constructors ‘’does not work’’ with pytz for many timezones.
[...]
"
This means that datetime for Toronto or Montreal must be constructed this way:
```
>>> toronto = pytz.timezone('America/Toronto')
>>> montreal = pytz.timezone('America/Montreal')
My understanding is that construction of a datetime using the constructor that takes a pytz timezone object is not supported (http:// pytz.sourceforg e.net/# localized- times-and- date-arithmetic /www.python. org/dev/ peps/pep- 0431/).
) due to a deficiency in the datetime API (https:/
Except from the first link above:
"This library only supports two ways of building a localized time. The first is to use the localize() method provided by the pytz library. This is used to localize a naive datetime (datetime with no timezone information):
[...]
The second way of building a localized time is by converting an existing localized time using the standard astimezone() method:
[...]
Unfortunately using the tzinfo argument of the standard datetime constructors ‘’does not work’’ with pytz for many timezones.
[...]
"
This means that datetime for Toronto or Montreal must be constructed this way:
``` 'America/ Toronto' ) 'America/ Montreal' )
>>> toronto = pytz.timezone(
>>> montreal = pytz.timezone(
>>> dtor = toronto. localize( datetime( 2019, 6, 6, 6, 6, 6, 6)) localize( datetime( 2019, 6, 6, 6, 6, 6, 6))
>>> dmon = montreal.
>>> print(dtor) 000006- 04:00
2019-06-06 06:06:06.
>>> print(dmon) 000006- 04:00
2019-06-06 06:06:06.
```