5 ms·
Am I right in thinking that if you always store in UTC, when the clocks go back you will get overlapping data? e.g. if you store your logs with a UTC date you'
by kpmah 8y ago
Am I right in thinking that if you always store in UTC, when the clocks go back you will get overlapping data?
e.g. if you store your logs with a UTC date you'll see interleaving logs for the extra hour, or if you read sensor data or something like that you'll get double readings?
- simcop2387 8y agoWell kind of. At least with how it works in the US. The first 2am is PST, the second 2am is PDT. so while they look the same, they're actually different times still. That said, rendering this for a user is still a pain depending on the UI.
- Qwertystop 8y agoNo? Or not necessarily, at least. For example, pytz (a Python timezone library) offers "is_dst" flags for exactly that purpose. >>> loc_dt = datetime(2002, 10, 27, 1, 30, 00) >>> est_dt = eastern.localize(loc_dt, is_dst=True) >>> edt_dt = eastern.localize(loc_dt, is_dst=False) >>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt)) 2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500 https://pythonhosted.org/pytz/#problems-with-localtime https://pythonhosted.org/pytz/#problems-with-localtime
- kpmah 8y agoYeah, I think I'm confusing storing things as UTC with storing things as UTC+0 - I forgot it stores the offset.