-
Notifications
You must be signed in to change notification settings - Fork 25
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
Inconsistent localization to timezones #6
Comments
Because it matches the ISO 8601 timestamp forma, foo = context.ZopeTime('2016-06-15T07:00:00')
bar = context.ZopeTime('2016/06/15 07:00:00')
print 'foo:', foo
print 'bar:', bar
return printed which produces the following output on my US/Eastern machine:
This idiosyncratic behavior is intentional, although the original cause for it is lost in the mists of time. |
thanks for you explanation @tseaver. i see that you've updated documentation a few years ago what i'm looking for is a way to tell if a DateTime object has real timezone information (that was given intentionally)
>>> aware = DateTime('2016/06/15 07:00:00 Europe/Vienna')
can i use the docstring suggests that it is used when converting between python datetime and zope DateTime objects.
but for me it looks like it is something i can rely on. it works for our unaware and aware objects >>> unaware.timezoneNaive()
True
>>> aware.timezoneNaive()
False and for those converted from python datetime >>> dt_aware = pytz.timezone('Europe/Vienna').localize(datetime(2016,6,15,7,0))
>>> dt_naive = datetime(2016,6,15,7,0)
>>> DateTime(dt_naive).timezoneNaive()
True
>>> DateTime(dt_aware).timezoneNaive()
False alternativesi can't use timezone since it always returns a GMT offset. >>> unaware.timezone()
'GMT+0'
>>> unaware2.timezone()
'GMT+2' or should i check for offset information in the ISO represenatation. >>> aware.ISO()
'2016-06-15T07:00:00+02:00'
>>> unaware.ISO()
'2016-06-15T07:00:00'
>>> unaware2.ISO()
'2016-06-15T07:00:00' |
while testing timezone handling in plone.app.event i stumbled upon this inconsistency.
Timezone-naive DateTime objects have the same .ISO() value but behave differently when localized to UTC:
can this difference be explained somehow or is this a bug?
The text was updated successfully, but these errors were encountered: