substanced icon indicating copy to clipboard operation
substanced copied to clipboard

When choosing datetimes, ensure that time is relative to user's timezone

Open mcdonc opened this issue 11 years ago • 8 comments

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.

mcdonc avatar Aug 10 '13 06:08 mcdonc

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

hirokiky avatar Apr 23 '14 09:04 hirokiky

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

sd_tz_sensitive

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.

hirokiky avatar Jun 14 '15 11:06 hirokiky

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.

cguardia avatar Jun 15 '15 03:06 cguardia

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.

mcdonc avatar Jun 15 '15 03:06 mcdonc

I like the notion of a show_timezone option for the widget (defaulting to false, I think).

tseaver avatar Jun 16 '15 07:06 tseaver

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..

hirokiky avatar Jun 16 '15 08:06 hirokiky

I fixed the code

  1. Use user.timezone if logged in
  2. Use browser timezone

And made it switchable to show or not.

hirokiky avatar Jun 16 '15 14:06 hirokiky

PR Opened!

hirokiky avatar Jun 16 '15 14:06 hirokiky