aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-11-18 13:02:34 +0200
committerEli Zaretskii2016-11-18 13:02:34 +0200
commit36bafc9cee918e88f9f62dd8ac2a1a0f6495c0b1 (patch)
treec4a455ec95b95c2a2bd2912fc3839ac812921ab1 /src
parenta37c08d524db722063111329458dc8f4368c46a2 (diff)
downloademacs-36bafc9cee918e88f9f62dd8ac2a1a0f6495c0b1.tar.gz
emacs-36bafc9cee918e88f9f62dd8ac2a1a0f6495c0b1.zip
Improve documentation of functions that accept time values
* doc/lispref/os.texi (Time Calculations): Mention the meaning of 'nil' or a scalar number as the time-value argument. Add a cross-reference to 'float-time' for computing a time difference as a scalar number of seconds. * src/editfns.c (Fformat_time_string, Ftime_less_p) (Ftime_subtract, Ftime_add, Fdecode_time, Fcurrent_time_string) (Fcurrent_time_zone): Mention in the doc strings the meaning of nil argument and the fact that a time value can be a scalar number of seconds since the epoch. (Ftime_subtract): Mention 'float-time'.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 403569f1fcd..5cc4a67ab19 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1581,21 +1581,28 @@ time_arith (Lisp_Object a, Lisp_Object b,
1581} 1581}
1582 1582
1583DEFUN ("time-add", Ftime_add, Stime_add, 2, 2, 0, 1583DEFUN ("time-add", Ftime_add, Stime_add, 2, 2, 0,
1584 doc: /* Return the sum of two time values A and B, as a time value. */) 1584 doc: /* Return the sum of two time values A and B, as a time value.
1585A nil value for either argument stands for the current time.
1586See `current-time-string' for the various forms of a time value. */)
1585 (Lisp_Object a, Lisp_Object b) 1587 (Lisp_Object a, Lisp_Object b)
1586{ 1588{
1587 return time_arith (a, b, time_add); 1589 return time_arith (a, b, time_add);
1588} 1590}
1589 1591
1590DEFUN ("time-subtract", Ftime_subtract, Stime_subtract, 2, 2, 0, 1592DEFUN ("time-subtract", Ftime_subtract, Stime_subtract, 2, 2, 0,
1591 doc: /* Return the difference between two time values A and B, as a time value. */) 1593 doc: /* Return the difference between two time values A and B, as a time value.
1594Use `float-time' to convert the difference into elapsed seconds.
1595A nil value for either argument stands for the current time.
1596See `current-time-string' for the various forms of a time value. */)
1592 (Lisp_Object a, Lisp_Object b) 1597 (Lisp_Object a, Lisp_Object b)
1593{ 1598{
1594 return time_arith (a, b, time_subtract); 1599 return time_arith (a, b, time_subtract);
1595} 1600}
1596 1601
1597DEFUN ("time-less-p", Ftime_less_p, Stime_less_p, 2, 2, 0, 1602DEFUN ("time-less-p", Ftime_less_p, Stime_less_p, 2, 2, 0,
1598 doc: /* Return non-nil if time value T1 is earlier than time value T2. */) 1603 doc: /* Return non-nil if time value T1 is earlier than time value T2.
1604A nil value for either argument stands for the current time.
1605See `current-time-string' for the various forms of a time value. */)
1599 (Lisp_Object t1, Lisp_Object t2) 1606 (Lisp_Object t1, Lisp_Object t2)
1600{ 1607{
1601 int t1len, t2len; 1608 int t1len, t2len;
@@ -1973,11 +1980,13 @@ emacs_nmemftime (char *s, size_t maxsize, const char *format,
1973} 1980}
1974 1981
1975DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, 1982DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0,
1976 doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted. 1983 doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted or nil.
1977TIME is specified as (HIGH LOW USEC PSEC), as returned by 1984TIME is specified as (HIGH LOW USEC PSEC), as returned by
1978`current-time' or `file-attributes'. The obsolete form (HIGH . LOW) 1985`current-time' or `file-attributes'.
1979is also still accepted. The optional ZONE is omitted or nil for Emacs 1986It can also be a single integer number of seconds since the epoch.
1980local time, t for Universal Time, `wall' for system wall clock time, 1987The obsolete form (HIGH . LOW) is also still accepted.
1988The optional ZONE is omitted or nil for Emacs local time,
1989t for Universal Time, `wall' for system wall clock time,
1981or a string as in the TZ environment variable. 1990or a string as in the TZ environment variable.
1982 1991
1983The value is a copy of FORMAT-STRING, but with certain constructs replaced 1992The value is a copy of FORMAT-STRING, but with certain constructs replaced
@@ -2094,7 +2103,9 @@ DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 2, 0,
2094 doc: /* Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST UTCOFF). 2103 doc: /* Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST UTCOFF).
2095The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED), 2104The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED),
2096as from `current-time' and `file-attributes', or nil to use the 2105as from `current-time' and `file-attributes', or nil to use the
2097current time. The obsolete form (HIGH . LOW) is also still accepted. 2106current time.
2107It can also be a single integer number of seconds since the epoch.
2108The obsolete form (HIGH . LOW) is also still accepted.
2098The optional ZONE is omitted or nil for Emacs local time, t for 2109The optional ZONE is omitted or nil for Emacs local time, t for
2099Universal Time, `wall' for system wall clock time, or a string as in 2110Universal Time, `wall' for system wall clock time, or a string as in
2100the TZ environment variable. 2111the TZ environment variable.
@@ -2219,8 +2230,10 @@ which provide a much more powerful and general facility.
2219If SPECIFIED-TIME is given, it is a time to format instead of the 2230If SPECIFIED-TIME is given, it is a time to format instead of the
2220current time. The argument should have the form (HIGH LOW . IGNORED). 2231current time. The argument should have the form (HIGH LOW . IGNORED).
2221Thus, you can use times obtained from `current-time' and from 2232Thus, you can use times obtained from `current-time' and from
2222`file-attributes'. SPECIFIED-TIME can also have the form (HIGH . LOW), 2233`file-attributes'. SPECIFIED-TIME can also be a single integer
2223but this is considered obsolete. 2234number of seconds since the epoch.
2235SPECIFIED-TIME can also have the form (HIGH . LOW), but this is
2236considered obsolete.
2224 2237
2225The optional ZONE is omitted or nil for Emacs local time, t for 2238The optional ZONE is omitted or nil for Emacs local time, t for
2226Universal Time, `wall' for system wall clock time, or a string as in 2239Universal Time, `wall' for system wall clock time, or a string as in
@@ -2298,8 +2311,9 @@ NAME is a string giving the name of the time zone.
2298If SPECIFIED-TIME is given, the time zone offset is determined from it 2311If SPECIFIED-TIME is given, the time zone offset is determined from it
2299instead of using the current time. The argument should have the form 2312instead of using the current time. The argument should have the form
2300\(HIGH LOW . IGNORED). Thus, you can use times obtained from 2313\(HIGH LOW . IGNORED). Thus, you can use times obtained from
2301`current-time' and from `file-attributes'. SPECIFIED-TIME can also 2314`current-time' and from `file-attributes'. SPECIFIED-TIME can also be
2302have the form (HIGH . LOW), but this is considered obsolete. 2315a single integer number of seconds since the epoch. SPECIFIED-TIME can
2316also have the form (HIGH . LOW), but this is considered obsolete.
2303Optional second arg ZONE is omitted or nil for the local time zone, or 2317Optional second arg ZONE is omitted or nil for the local time zone, or
2304a string as in the TZ environment variable. 2318a string as in the TZ environment variable.
2305 2319