From: Michael Heerdegen <michael_heerdegen@web.de>
To: Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Time zone trouble without time zones being involved
Date: Sun, 03 Apr 2016 08:11:55 +0200 [thread overview]
Message-ID: <87shz3cjbo.fsf@web.de> (raw)
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.
next reply other threads:[~2016-04-03 6:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-03 6:11 Michael Heerdegen [this message]
2016-04-03 6:43 ` Time zone trouble without time zones being involved Yuri Khan
2016-04-13 16:14 ` Michael Heerdegen
2016-04-13 16:48 ` Yuri Khan
2016-04-13 17:16 ` Michael Heerdegen
2016-04-13 17:40 ` Yuri Khan
2016-05-14 18:53 ` Michael Heerdegen
2016-05-14 21:51 ` Yuri Khan
2016-05-16 15:47 ` Michael Heerdegen
2016-05-16 16:06 ` Yuri Khan
2016-05-17 14:57 ` Michael Heerdegen
2016-05-17 15:31 ` Yuri Khan
2016-05-17 16:19 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87shz3cjbo.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.