Closed numberoverzero closed 6 years ago
Is convert datetime.timezone
and pytz.timezone
to Delorean().shift()
a good solution to these problem?
Because it currently take the argument from Delorean().shift()
directly to pytz.timezone()
constructor.
You should always use UTC
why would you pull in datetime to just ask for utc
timezone. There are few examples that cover what you are trying to do at http://delorean.rtfd.org.
Thanks for the response. I'm pulling in datetime for more than utc but wanted to provide a minimal example. I'll use "UTC"
instead.
I was hoping that .shift
would handle a datetime.tzinfo
instance (as well as a string through the use of pytz
) because I provide a library that maps dynamodb objects to python types, and I include an extension for Delorean which simply forwards the users' timezone
parameter through.
I expect most users will provide a string such as "utc" and things will be fine, but some may use a custom datetime.tzinfo
subclass; datetime.timezone
is simply a concrete example of the problem. From the docs:
Note that only one concrete tzinfo class, the timezone class, is supplied by the datetime module. The timezone class can represent simple timezones with fixed offset from UTC, such as UTC itself or North American EST and EDT timezones.
To reproduce:
From these lines, Delorean doesn't support anything outside of
pytz.timezone
ability to parse, which breaks onzone.upper()
at the beginning of this method.Should I always use
"UTC"
instead of datetime's provideddatetime.timezone.utc
? I was hoping to reuse the standard library's version across different datetime libraries.