diff options
| author | Bob Rogers | 2023-10-12 10:23:35 -0700 |
|---|---|---|
| committer | Eli Zaretskii | 2023-10-14 11:57:30 +0300 |
| commit | 0ea2d6d9e82d2f88af4545f4b74c48989bf3415d (patch) | |
| tree | 48fb29865264130a480eecb97cfd255a46a77023 | |
| parent | dc8b336d0254d751ffcb2466a20a650ca9c5f86a (diff) | |
| download | emacs-0ea2d6d9e82d2f88af4545f4b74c48989bf3415d.tar.gz emacs-0ea2d6d9e82d2f88af4545f4b74c48989bf3415d.zip | |
Document that time-to-days and days-to-time use different epochs
* doc/lispref/os.texi (Time Calculations):
* lisp/calendar/time-date.el (days-to-time, time-to-days): Doc fixes.
(Bug#66502)
| -rw-r--r-- | doc/lispref/os.texi | 8 | ||||
| -rw-r--r-- | lisp/calendar/time-date.el | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 7c8b35236cd..ea27af8edb2 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -2104,6 +2104,14 @@ This function returns the number of days between the beginning of year | |||
| 2104 | The operating system limits the range of time and zone values. | 2104 | The operating system limits the range of time and zone values. |
| 2105 | @end defun | 2105 | @end defun |
| 2106 | 2106 | ||
| 2107 | @defun days-to-time days | ||
| 2108 | This is not quite the inverse of the @code{time-to-days} function, as | ||
| 2109 | it uses the Emacs epoch (instead of the year 1) for historical | ||
| 2110 | reasons. To get the inverse, subtract @code{(time-to-days 0)} from | ||
| 2111 | @var{days}, in which case @code{days-to-time} may return @code{nil} if | ||
| 2112 | @var{days} is negative. | ||
| 2113 | @end defun | ||
| 2114 | |||
| 2107 | @defun time-to-day-in-year time-value | 2115 | @defun time-to-day-in-year time-value |
| 2108 | This returns the day number within the year corresponding to @var{time-value}, | 2116 | This returns the day number within the year corresponding to @var{time-value}, |
| 2109 | assuming the default time zone. | 2117 | assuming the default time zone. |
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 9cbe8e0f53c..786134d8ac5 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el | |||
| @@ -181,7 +181,10 @@ If DATE lacks timezone information, GMT is assumed." | |||
| 181 | 181 | ||
| 182 | ;;;###autoload | 182 | ;;;###autoload |
| 183 | (defun days-to-time (days) | 183 | (defun days-to-time (days) |
| 184 | "Convert DAYS into a time value." | 184 | "Convert Emacs-epoch DAYS into a time value. |
| 185 | Note that this does not use the same epoch as time-to-days; you | ||
| 186 | must subtract (time-to-days 0) first to convert, and may get nil | ||
| 187 | if the result is before the start." | ||
| 185 | ;; FIXME: We should likely just pass `t' to `time-convert'. | 188 | ;; FIXME: We should likely just pass `t' to `time-convert'. |
| 186 | ;; All uses I could find in Emacs, GNU ELPA, and NonGNU ELPA can handle | 189 | ;; All uses I could find in Emacs, GNU ELPA, and NonGNU ELPA can handle |
| 187 | ;; any valid time representation as return value. | 190 | ;; any valid time representation as return value. |
| @@ -243,7 +246,7 @@ DATE1 and DATE2 should be date-time strings." | |||
| 243 | 246 | ||
| 244 | ;;;###autoload | 247 | ;;;###autoload |
| 245 | (defun time-to-days (time) | 248 | (defun time-to-days (time) |
| 246 | "The absolute date corresponding to TIME, a time value. | 249 | "The absolute pseudo-Gregorian date for TIME, a time value. |
| 247 | The absolute date is the number of days elapsed since the imaginary | 250 | The absolute date is the number of days elapsed since the imaginary |
| 248 | Gregorian date Sunday, December 31, 1 BC." | 251 | Gregorian date Sunday, December 31, 1 BC." |
| 249 | (let* ((tim (decode-time time)) | 252 | (let* ((tim (decode-time time)) |