Skip to content

Support offset-only tzinfo objects #59

@danpalmer

Description

@danpalmer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions