-
Notifications
You must be signed in to change notification settings - Fork 129
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 for when only time zone UTC offsets are known #40
Comments
I'm happy to dive in and see if I can get this working if we can decide on the best approach, so let me know if you'd be open to receiving some pull requests ;-) |
@mwaterfall have you tried using the parse functionality inside delorean? I think it supports ISO 8601? If not, let me see what I can do it. |
Looks like it converts it to UTC, I might have sometime this weekend. |
Yes it supports and parses ISO 8601 perfectly, however as you say, Delorean returns the correct time in UTC. As dates with a UTC offset in hours/mins are common over the internet it would be great if it could be handled. I've just seen the tzoffset type that dateutil offers, so that's useful. It looks like RFC822 dates use the same format for offsets too, so parsing the offset in hours/mins from the string should be fairly straightforward. Let me know if I can be of any help! |
@mwaterfall - I'm having a hard time parsing your problem. It sounds like you are able to use If you knew the name of the timezone that for the datetime, you could convert it using shift, but shift does not understand fixed offset. In other words, what you would like to do is something like the following: >>> d = parse('2015-01-01 00:00:00 -0800')
>>> d.shift('-0800')
>>> d.datetime
datetime.datetime(2015, 1, 1, 0, 0, tzinfo=tzoffset(None, -28800)) The other option I can imagine is a new class property that returns a localized datetime object, like this: >>> d = parse('2015-01-01 00:00:00 -0800')
>>> d.local_datetime
datetime.datetime(2015, 1, 1, 0, 0, tzinfo=tzoffset(None, -28800)) The first change seems pretty simple, but the second will require a bit more work because Delorean objects will have to remember their local timezone after they've been parsed. I have a feeling you're looking for the functionality in the later. Can you confirm? |
I'm having to handle time zones where I only know the UTC offset and no specific time zone identifier string. I'd still like to be able to plug in these into Delorean as my app is already built around Delorean because of it's awesomeness!
I'm generating
tzinfo
objects using pytz's (rather hidden)FixedOffset
class, but as there is no standard for naming such offsets, there's no way for me to plug them in to Delorean.So it would be awesome if I could either pass
tzinfo
objects straight into anytimezone
argument, or whether Delorean could parse certain strings (perhaps in the ISO 8601 UTC time offset format i.e.±hh:mm
,±hhmm
,±hh
) and then Delorean could create tzinfo objects from those using theFixedOffset
class or similar.Would be great to hear your thoughts.
The text was updated successfully, but these errors were encountered: