help-gnu-emacs
[Top][All Lists]
Advanced

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

Counterpart to time-to-days?


From: Tim Landscheidt
Subject: Counterpart to time-to-days?
Date: Wed, 29 May 2019 12:20:49 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hi,

prologue: With GNU Emacs 26.1, I have a list of UTC time-
stamp pairs that I want to transpose to the Europe/Berlin
time zone and group by a calculated "day" to print a shift-
plan.  For example, 2019-05-29T17:45:00Z gets (currently)
transformed to something similar to '(29 19 45), while
2019-05-29T22:30:00Z gets transformed to '(29 24 30) and
2019-05-30T03:30:00Z to '(29 29 30).  This part works just
fine.

Now I want to group and display them by week and day.  So I
applied time-to-days to the transposed timestamps (and then
planned to calculate the preceding Mondays for the minimum
and maximum days and iterate between them), but when I want-
ed to reconvert the day numbers with the fitting-by-name
days-to-time to display it as a date I hit the following id-
iosyncrasy:

| ELISP> (format-time-string "%F" (current-time))
| "2019-05-29"
| ELISP> (format-time-string "%F" (days-to-time (time-to-days (current-time))))
| "3988-05-29"
| ELISP>

So time-to-days seems to count the days from 0001-12-31bce,
while days-to-time (without being explicit about it) seems
to treat days as counting from epoch (1970-01-01).

What is the intended counterpart to time-to-days?  How is
date arithmetic supposed to be done in Emacs Lisp?

TIA,
Tim




reply via email to

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