emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Idea for handling timezones


From: Shironeko
Subject: Re: Idea for handling timezones
Date: Sat, 03 Apr 2021 17:26:43 +0800
User-agent: Evolution 3.38.4

tz database and tools using it like the date(1) command can convert between
local times taking into account all the difference like daylight savings time.
An example below, Toronto observes daylight savings whereas Shanghai does not:

$ TZ=Asia/Shanghai date --date='TZ="America/Toronto" 2021-11-07 Sun 00:30'
Sun  7 Nov 12:30:00 CST 2021
$ TZ=Asia/Shanghai date --date='TZ="America/Toronto" 2021-11-07 Sun 01:30'
Sun  7 Nov 13:30:00 CST 2021
$ TZ=Asia/Shanghai date --date='TZ="America/Toronto" 2021-11-07 Sun 02:30'
Sun  7 Nov 15:30:00 CST 2021

$ TZ=America/Toronto date --date='TZ="Asia/Shanghai" 2021-11-07 Sun 12:30'
Sun  7 Nov 00:30:00 EDT 2021
$ TZ=America/Toronto date --date='TZ="Asia/Shanghai" 2021-11-07 Sun 13:30'
Sun  7 Nov 01:30:00 EDT 2021
$ TZ=America/Toronto date --date='TZ="Asia/Shanghai" 2021-11-07 Sun 14:30'
Sun  7 Nov 01:30:00 EST 2021
$ TZ=America/Toronto date --date='TZ="Asia/Shanghai" 2021-11-07 Sun 15:30'
Sun  7 Nov 02:30:00 EST 2021

The ambiguity caused by dialing back is resolved with
$ TZ=Asia/Shanghai date --date='TZ="America/Toronto" 2021-11-07 Sun 01:30 EDT'
Sun  7 Nov 13:30:00 CST 2021
$ TZ=Asia/Shanghai date --date='TZ="America/Toronto" 2021-11-07 Sun 01:30 EST'
Sun  7 Nov 14:30:00 CST 2021

With this, say the user have

#+TIMEZONE: America/Toronto

at the start of their org file, and they moved to Shanghai, all the timestamp in
the org file is converted using something equivalent to

$ TZ=Asia/Shanghai date --date='TZ="America/Toronto" '"$TIMESTAMP"

and the file header changed to

#+TIMEZONE: Asia/Shanghai

when they get back the timestamp is returned with
$ TZ=America/Toronto date --date='TZ="Asia/Shanghai" '"$TIMESTAMP"

shiro

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]