Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support offset-only tzinfo objects #59

Open
danpalmer opened this issue Apr 11, 2020 · 0 comments
Open

Support offset-only tzinfo objects #59

danpalmer opened this issue Apr 11, 2020 · 0 comments

Comments

@danpalmer
Copy link
Contributor

It's possible for a tzinfo object to only have an offset and no named timezone. For example:

>>> dateutil.parser.parse('2020-04-12 00:26 +1')
datetime.datetime(2020, 4, 12, 0, 26, tzinfo=tzoffset(None, 3600))

Because these don't have a name, we can't set the TZ environment variable with the name straight from tzname or zone (see #58 for some context on that difference).

I'd suggest that a good solution might be to use the same behaviour as already exists here

self.timezone_str = 'Etc/GMT{0:+}'.format(-tz_offset)

It may be necessary to support both the tz_offset argument and the offset in the datetime_spec.tzinfo in the case that it's a datetime. It may also be necessary to combine these, but I'm not quite sure what the desired behaviour is when both a tz_offset and a timezone-aware datetime are provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant