Date and Time #366
Replies: 2 comments 2 replies
-
Hi, I'm glad that you like Jennifer. Time zone related questions are always pretty complicated. I will take a look what can be done to provide the post flexible interface that can be achieved |
Beta Was this translation helpful? Give feedback.
-
If you have users in multiple time zones inputting events then either:
You can't have the db automatically apply the user's time zone to a Consider |
Beta Was this translation helpful? Give feedback.
-
Hi, firstly, thanks for Jennifer, it's a nice ORM and we enjoy using it!
One way in which it appears to differ from Granite (for example) is the handling of TIMESTAMP (WITHOUT TIME ZONE) columns (at least in Postgres).
When it comes to this type of column, one can't safely assume that the value in the database should be an absolute UTC time stamp.
There is a case where it is desirable to be able to store a local time at face value into a TIMESTAMP field and to then be able to have that time load back directly at a specified local time. As things are now, it's reasonable to make a case for converting to UTC on save by default, on the basis of consistency - but some applications are built to support users from multiple time zones who are inputting events, that are to occur at a future date, in their local zone. It should be fine in those cases, to be able to store just the wall clock time as-is, without shifting to UTC before persisting.
It appears that Jennifer does convert (changing the wall clock time) to UTC, undoing any local time offset, before persisting the data for this column type, and performs the reverse, reapplying the offset when loading the date.
I'd like to suggest that (for TIMESTAMP WITHOUT TIME ZONE) only, Jennifer persist the Time object at face value without converting to UTC before storage. If the system time is already UTC, it will end up UTC as normal, but when the time is not UTC, it would store the wall clock time at the zone specified by Time::Location.local
Then, it would be nice to be able to specify at which zone the time is supposed to be interpreted when fetching (by specifying the timezone to use at runtime for dynamic cases where each application user may have their own zone.
Beta Was this translation helpful? Give feedback.
All reactions