[MDEV-17824] Convert between UTC datetime and UNIX timestamps without referencing timezone Created: 2018-11-25 Updated: 2018-11-25 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Temporal Types |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Dean Trower | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | timestamp, timezones | ||
| Description |
|
MariaDB desperately needs functions corresponding to FROM_UNIXTIME() and UNIX_TIMESTAMP, but that work strictly in UTC - that is, a: UTC_FROM_UNIXTIME() that returns a UTC date from a unix timestamp, and This can be achieved already by doing a SET @@time_zone:='+00:00' before using the existing functions, but that is inconvenient if you also wish to use local times in the same query. It's important because the conversion is not reliable in any timezone that has DST. Programmers should be able to convert UTC datetimes to UNIX timestamps and back simply and easily, without the conversion breaking one hour out of every year in some locales, and without having to do anything to (or even think about!) session timezone settings.
Assume LastModTime is a DATETIME field storing a UTC value...
This works... but seriously, waaay overcomplicated!!!
Simple, clear, and no non-obvious once-per-year bugs relating to timezones!
|