[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Time zone trouble without time zones being involved
From: |
Michael Heerdegen |
Subject: |
Time zone trouble without time zones being involved |
Date: |
Sun, 03 Apr 2016 08:11:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Hello,
I'm using git to make a backup of the file I'm working with after every
save. I want to display the age of the last backup made in the
mode-line.
To be able to control the time display format from Elisp, I decided to
ask git-log for the time since "the Epoch":
#+begin_src emacs-lisp
(string-to-number
(helm-backup-exec-git-command "log" ref "--pretty=format:%ad"
"--date=format:%s" "-n1"
filename-for-git))
#+end_src
(where `helm-backup-exec-git-command' just calls "git" with the
specified args).
"%ad" means "author date", and "%s" means, according to "man strftime",
"The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
(TZ) (Calculated from mktime(tm).)"
After saving a file, this value is saved to the local variable
`helm-backup-time-of-latest-backup'.
In the mode-line, I show this:
#+begin_src emacs-lisp
(helm-backup-time-of-latest-backup
(:eval
(progn
(require 'timeclock)
(propertize (concat " "
(timeclock-seconds-to-string
(time-to-seconds
(time-subtract (current-time)
(seconds-to-time
helm-backup-time-of-latest-backup))))
"h")
'face 'mode-line-shadow))))
#+end_src
The problem: since we have Daylight saving time, this always shows one
hour less than the expected value (directly after saving it shows
-0:59h). This makes no sense to me, since I only work with "seconds
since Epoch" absolute time values that I thought would not depend on the
local time zone. So either git or Emacs seems to make an error.
Do I miss something? How can I prevent that wrong behavior?
Thanks,
Michael.
- Time zone trouble without time zones being involved,
Michael Heerdegen <=