diff options
| author | Eli Zaretskii | 2016-11-18 13:02:34 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2016-11-18 13:02:34 +0200 |
| commit | 36bafc9cee918e88f9f62dd8ac2a1a0f6495c0b1 (patch) | |
| tree | c4a455ec95b95c2a2bd2912fc3839ac812921ab1 /src | |
| parent | a37c08d524db722063111329458dc8f4368c46a2 (diff) | |
| download | emacs-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.c | 38 |
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 | ||
| 1583 | DEFUN ("time-add", Ftime_add, Stime_add, 2, 2, 0, | 1583 | DEFUN ("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. |
| 1585 | A nil value for either argument stands for the current time. | ||
| 1586 | See `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 | ||
| 1590 | DEFUN ("time-subtract", Ftime_subtract, Stime_subtract, 2, 2, 0, | 1592 | DEFUN ("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. |
| 1594 | Use `float-time' to convert the difference into elapsed seconds. | ||
| 1595 | A nil value for either argument stands for the current time. | ||
| 1596 | See `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 | ||
| 1597 | DEFUN ("time-less-p", Ftime_less_p, Stime_less_p, 2, 2, 0, | 1602 | DEFUN ("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. |
| 1604 | A nil value for either argument stands for the current time. | ||
| 1605 | See `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 | ||
| 1975 | DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, | 1982 | DEFUN ("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. |
| 1977 | TIME is specified as (HIGH LOW USEC PSEC), as returned by | 1984 | TIME 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'. |
| 1979 | is also still accepted. The optional ZONE is omitted or nil for Emacs | 1986 | It can also be a single integer number of seconds since the epoch. |
| 1980 | local time, t for Universal Time, `wall' for system wall clock time, | 1987 | The obsolete form (HIGH . LOW) is also still accepted. |
| 1988 | The optional ZONE is omitted or nil for Emacs local time, | ||
| 1989 | t for Universal Time, `wall' for system wall clock time, | ||
| 1981 | or a string as in the TZ environment variable. | 1990 | or a string as in the TZ environment variable. |
| 1982 | 1991 | ||
| 1983 | The value is a copy of FORMAT-STRING, but with certain constructs replaced | 1992 | The 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). |
| 2095 | The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED), | 2104 | The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED), |
| 2096 | as from `current-time' and `file-attributes', or nil to use the | 2105 | as from `current-time' and `file-attributes', or nil to use the |
| 2097 | current time. The obsolete form (HIGH . LOW) is also still accepted. | 2106 | current time. |
| 2107 | It can also be a single integer number of seconds since the epoch. | ||
| 2108 | The obsolete form (HIGH . LOW) is also still accepted. | ||
| 2098 | The optional ZONE is omitted or nil for Emacs local time, t for | 2109 | The optional ZONE is omitted or nil for Emacs local time, t for |
| 2099 | Universal Time, `wall' for system wall clock time, or a string as in | 2110 | Universal Time, `wall' for system wall clock time, or a string as in |
| 2100 | the TZ environment variable. | 2111 | the TZ environment variable. |
| @@ -2219,8 +2230,10 @@ which provide a much more powerful and general facility. | |||
| 2219 | If SPECIFIED-TIME is given, it is a time to format instead of the | 2230 | If SPECIFIED-TIME is given, it is a time to format instead of the |
| 2220 | current time. The argument should have the form (HIGH LOW . IGNORED). | 2231 | current time. The argument should have the form (HIGH LOW . IGNORED). |
| 2221 | Thus, you can use times obtained from `current-time' and from | 2232 | Thus, 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 |
| 2223 | but this is considered obsolete. | 2234 | number of seconds since the epoch. |
| 2235 | SPECIFIED-TIME can also have the form (HIGH . LOW), but this is | ||
| 2236 | considered obsolete. | ||
| 2224 | 2237 | ||
| 2225 | The optional ZONE is omitted or nil for Emacs local time, t for | 2238 | The optional ZONE is omitted or nil for Emacs local time, t for |
| 2226 | Universal Time, `wall' for system wall clock time, or a string as in | 2239 | Universal 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. | |||
| 2298 | If SPECIFIED-TIME is given, the time zone offset is determined from it | 2311 | If SPECIFIED-TIME is given, the time zone offset is determined from it |
| 2299 | instead of using the current time. The argument should have the form | 2312 | instead 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 |
| 2302 | have the form (HIGH . LOW), but this is considered obsolete. | 2315 | a single integer number of seconds since the epoch. SPECIFIED-TIME can |
| 2316 | also have the form (HIGH . LOW), but this is considered obsolete. | ||
| 2303 | Optional second arg ZONE is omitted or nil for the local time zone, or | 2317 | Optional second arg ZONE is omitted or nil for the local time zone, or |
| 2304 | a string as in the TZ environment variable. | 2318 | a string as in the TZ environment variable. |
| 2305 | 2319 | ||