summaryrefslogtreecommitdiff
path: root/src/timefns.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2022-04-16 18:48:51 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2022-04-16 18:54:31 -0700
commitf1ba92448d1e573640547c68d9bed89fe5c43da0 (patch)
tree78f126665a9b1a72206198f8b1af65ff14f59538 /src/timefns.c
parent15a5cf9a9aa7798ee12ae96b8b6b4efe1562b57e (diff)
Document encode-time caveats
* doc/lispref/os.texi (Time of Day, Time Conversion): Move the warnings about DST being -1 to closer to where DST is discussed, and reword and improve the discussions and warnings. Be more precise about years before 1969 (possible west of UTC) vs the Epoch. Mention some problems due to leap seconds, leap years, daylight saving transitions, and time zone changes. Modernize discussion of OS timestamp range. Prefer secular ‘BCE’ to religious ‘BC’. Omit discussion of decoded-time-add and make-decoded-time, as they are in a library and are not always available; instead, mention the library. Warn about common mistakes when doing simple date arithmetic. * src/timefns.c (Fencode_time): In doc string, mention date arithmetic and tighten up the wording a bit.
Diffstat (limited to 'src/timefns.c')
-rw-r--r--src/timefns.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/timefns.c b/src/timefns.c
index 9af89a512db..7a4a7075edc 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -1609,11 +1609,11 @@ check_tm_member (Lisp_Object obj, int offset)
DEFUN ("encode-time", Fencode_time, Sencode_time, 1, MANY, 0,
doc: /* Convert TIME to a timestamp.
-TIME is a list (SECOND MINUTE HOUR DAY MONTH YEAR IGNORED DST ZONE).
+TIME is a list (SECOND MINUTE HOUR DAY MONTH YEAR IGNORED DST ZONE)
in the style of `decode-time', so that (encode-time (decode-time ...)) works.
In this list, ZONE can be nil for Emacs local time, t for Universal
Time, `wall' for system wall clock time, or a string as in the TZ
-environment variable. It can also be a list (as from
+environment variable. ZONE can also be a list (as from
`current-time-zone') or an integer (as from `decode-time') applied
without consideration for daylight saving time. If ZONE specifies a
time zone with daylight-saving transitions, DST is t for daylight
@@ -1626,14 +1626,12 @@ DAY, MONTH, and YEAR, and specify the components of a decoded time.
If there are more than 6 arguments the *last* argument is used as ZONE
and any other extra arguments are ignored, so that (apply
#\\='encode-time (decode-time ...)) works. In this obsolescent
-convention, DST and ZONE default to -1 and nil respectively.
+convention, DST is -1 and ZONE defaults to nil.
-Years before 1970 are not guaranteed to work. On some systems,
-year values as low as 1901 do work.
-
-See Info node `(elisp)Time Conversion' for description of a pitfall
-that can be faced during migration from the obsolescent to the new
-calling convention due to unconscious usage of nil for the DST argument.
+The range of supported years is at least 1970 to the near future.
+Out-of-range values for SECOND through MONTH are brought into range
+via date arithmetic. This can be tricky especially when combined with
+DST; see Info node `(elisp)Time Conversion' for details and caveats.
usage: (encode-time TIME &rest OBSOLESCENT-ARGUMENTS) */)
(ptrdiff_t nargs, Lisp_Object *args)