substanced
substanced copied to clipboard
When choosing datetimes, ensure that time is relative to user's timezone
Might need to make a new schema node type based on colander.DateTime that automatically sets the tzinfo to the user's timezone, and returns a datetime converted to UTC.
Now the /index.atom of demo blog app causes Error on my enviroment. it is mainly due to this issue, right?
2014-04-23 18:18:59,630 ERROR [waitress][Dummy-2] Exception when serving /index.atom
Traceback (most recent call last):
...
File "/Users/hirokiky/dev/substanced-blog/substanced-blog/blog/views/retail.py", line 224, in blog_atom
feed, blogentries = self._get_feed_info()
File "/Users/hirokiky/dev/substanced-blog/substanced-blog/blog/views/retail.py", line 197, in _get_feed_info
_add_updated_strings(updated, info)
File "/Users/hirokiky/dev/substanced-blog/substanced-blog/blog/views/retail.py", line 183, in _add_updated_strings
info['updated_atom'] = updated.astimezone(pytz.utc).isoformat()
ValueError: astimezone() cannot be applied to a naive datetime
I created DateTime SchemaNode and Widget handling timezone. https://github.com/hirokiky/substanced/commit/b913502d3f367e0cfe5eac2dafa3a7bc7635fcf2
- Client users' timezone will be applied at the first time.
- Users can change the value
- If changing existing data, the default value of timezone input will be filled by the data
Like this
Thinking...
- This feature should be separated from substanced, and included in deform
- TimeZone should not be appeared by default
- config-able would be nice
Special thanks for tsearver for giving some advices at PloneSymposiumTokyo Sprint.
I'd say if it's generally useful, try to make a PR to deform. I agree that it's best if it doesn't appear by default. Maybe if configured to not show time zone, get it from the user's system by default.
I'd suggest putting it in Substance D right now and backporting it to deform later to be honest. I'm sure it's generally useful enough to add to deform but I dont anticipate a new deform release any time soon.
I like the notion of a show_timezone
option for the widget (defaulting to false, I think).
Thank you.
anyway now I noticed User has timezone
property.
Did @mcdonc say to use this value? My changes uses timezone info from browser (JavaScript).
I feel user.timezone
is better.
Ofcause users are not logged in for all of times..
I fixed the code
- Use user.timezone if logged in
- Use browser timezone
And made it switchable to show or not.
PR Opened!