17

When I write something like this: <2015-07-05 Sun 20:00 GMT+0>, and then try to edit it by pressing C-c ., Org removes the GMT+0 part. So, I think it's in a wrong format.

Note: I don't want to set my time to a different timezone. I want dates in a particular document to be in that timezone.

wvxvw
  • 11,222
  • 2
  • 30
  • 55
  • This sounds like a feature request. – Andrew Swann Jun 26 '15 at 11:51
  • @AndrewSwann oh, I thought there was a way... I think I saw Org dates with a timezone, just couldn't remember where. I'll write to the mailing list then to make sure. – wvxvw Jun 26 '15 at 13:30
  • @AndrewSwann yup, it seems like that's not possible now, and not planned in the near future, so, if you want to, you can make it an answer. – wvxvw Jun 26 '15 at 19:05
  • @wvxvw asked the devs too https://lists.gnu.org/archive/html/emacs-orgmode/2015-06/msg00644.html – I don't think anything came of it unfortunately :( This would be a nice feature to have for e.g. when you live in a DST time zone, and have a recurring chat with someone in a non-DST time zone. – unhammer May 24 '17 at 11:06
  • (I ended up adding my event twice, using `<%%(diary-float '(…) …)>` to split up the months into DST vs non-DST) – unhammer May 24 '17 at 11:15
  • @unhammer Please show us exactly what you did using `diary-float` – Phil Hudson Feb 15 '22 at 09:39
  • e.g. `SCHEDULED: <%%(diary-float t 4 (- 1))%>` would give do the last Thursday of the month. Unfortunately org-ql doesn't support it. – unhammer Feb 16 '22 at 12:07

2 Answers2

6

Time zone informatian is not currently part of date formats in org-mode and thus not part of the output from C-c .. Like C-c C-c on a timestamp any extraneous material in the date specification is removed and the week day is corrected to fit a given date, so partial junk input like

 13-6-3 Wed Xyz 13:00

is output as

 <2013-06-03 Mon 13:00>

a correct date, with matching day name.

It might be appropriate to make a feature request to the org-mode developers.

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43
  • Customizing `org-time-stamp-formats` will do part of the trick for every timestamps that orgmode generates and handle. It'll work as long as you want to store your local timezone with any timestamps orgmode generates. See my full answer – vaab Sep 10 '20 at 05:55
3

Note: this only stores the local timezone and keep it in your timestamps. It'll replace any timezone information by your local one. But at least it'll store your current local one.

Note2: all timestamps will work to my knowledge, but time ranges are then ambiguously displayed. Thanks to @He Yifei 何一非 to bring that up.

This is what I did:

  (setq org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M %Z>"))

The important part is the %Z.

default is (from orgmode source):

(defconst org-time-stamp-formats '("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M>")
  "Formats for `format-time-string' which are used for time stamps.")

With this setting, all instances of timestamps in orgmode that I use and can think of get the timezone information added (ie: <2020-09-15 Tue 09:00 CEST>):

  • modifying dates by hand and using C-c C-c (timezone will get added if missing)
  • Clockin and Clockout with C-c C-x C-i / C-c C-x C-o
  • CLOSED, SCHEDULED, DEADLINE
  • org-time-stamp when inserting time and not only date info

And I didn't notice any issue, except that time ranges are not really useable (I don't use them). I'm using quite extensively all the clock/timestamps. This setting is available in orgmode for a very long time, before 2008 for sure, according to org git repository.

Let me add the fact that you should probably NEVER store naive timestamps (without timezones) anywhere. It is a pity that orgmode does this by default. Thankfully, it is easy to fix.

vaab
  • 315
  • 1
  • 7
  • Duration becomes something like this `2020-09-15 Tue 07:00 PDT-07:50` which isn't desirable. Any way to make it e.g., `2020-09-15 Tue 07:00 PDT-07:50 PDT`? – He Yifei 何一非 Sep 15 '20 at 03:47
  • Not sure if I'm looking at the right file, but https://github.com/bzg/org-mode/blob/817c0c81e8f6d1dc387956c8c5b026ced62c157c/lisp/org-element.el#L3690 seems to suggest that the `-HH:MM` part is hardcoded. – He Yifei 何一非 Sep 15 '20 at 03:54
  • @HeYifei何一非 Timestamps in my system with this setup are without the ending `-HH:MM`: here's one for instance: `<2020-09-15 Tue 09:00 CEST>` (I added this as an example in the answer also). The code you pointed at is about timestamp vs datestamp. What are you calling "duration" ? – vaab Sep 15 '20 at 10:06
  • I was referring to "time range": https://orgmode.org/manual/The-date_002ftime-prompt.html "You can specify a time range by giving start and end times or by giving a start time and a duration (in HH:MM format). Use one or two dash(es) as the separator in the former case and use ‘+’ as the separator in the latter case," Like when you are entering schedule, type `7:00+0:50` (or `7:00-7:50`) and press enter, it gives `2020-09-15 Tue 07:00 PDT-07:50`. – He Yifei 何一非 Sep 16 '20 at 11:54
  • 1
    I never used time ranges, and did not know their existences. Thanks for allowing me to learn about them. I edited my answer to add a proper warning. A question arise, wouldn't these should be simply written as 2 timestamps separated by dashes ? Just as clockin/clockout does. It's lengthy but quite readable. I figure this shouldn't be very complicated to implement. Are there a lot of place were time ranges are actually used ? I'll definitively have a look. – vaab Sep 16 '20 at 21:49
  • I feel like it is usually used for scheduling? But yeah, two timestamps work well too. Anyway, thanks for providing a solution to add the timezone! It is really helpful :) – He Yifei 何一非 Sep 17 '20 at 04:17
  • Also curiously, manually-typed `<2020-09-17 Thu 08:00-10:55 PDT>` can be parsed fully (`10:55` part is parsed) while the auto-generated `<2020-09-17 Thu 08:00 PDT-10:55>` cannot be parsed fully (`10:55` part is dropped). Feels like the generator and the parser might not be consistent for this. – He Yifei 何一非 Sep 17 '20 at 04:20