unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Time zone trouble without time zones being involved
@ 2016-04-03  6:11 Michael Heerdegen
  2016-04-03  6:43 ` Yuri Khan
  0 siblings, 1 reply; 13+ messages in thread
From: Michael Heerdegen @ 2016-04-03  6:11 UTC (permalink / raw)
  To: Emacs mailing list

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.



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-05-17 16:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-03  6:11 Time zone trouble without time zones being involved Michael Heerdegen
2016-04-03  6:43 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).