diff options
| author | Richard M. Stallman | 2002-02-01 04:28:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-02-01 04:28:28 +0000 |
| commit | baee139771cbfe6b76522e536afccc4099700e58 (patch) | |
| tree | 145bc57fa24007903670a7cce844b26b65c2c82d | |
| parent | 3efadcb8768cc57889ae32a580068c3bcc1387a1 (diff) | |
| download | emacs-baee139771cbfe6b76522e536afccc4099700e58.tar.gz emacs-baee139771cbfe6b76522e536afccc4099700e58.zip | |
Document date-to-time and seconds-to-time.
New node Time Calculations.
| -rw-r--r-- | lispref/os.texi | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lispref/os.texi b/lispref/os.texi index d6a58910f40..d035f58d396 100644 --- a/lispref/os.texi +++ b/lispref/os.texi | |||
| @@ -23,6 +23,7 @@ pertaining to the terminal and the screen. | |||
| 23 | * Time of Day:: Getting the current time. | 23 | * Time of Day:: Getting the current time. |
| 24 | * Time Conversion:: Converting a time from numeric form to a string, or | 24 | * Time Conversion:: Converting a time from numeric form to a string, or |
| 25 | to calendrical data (or vice versa). | 25 | to calendrical data (or vice versa). |
| 26 | * Time Calculations:: Adding, subtracting, comparing times, etc. | ||
| 26 | * Timers:: Setting a timer to call a function at a certain time. | 27 | * Timers:: Setting a timer to call a function at a certain time. |
| 27 | * Terminal Input:: Recording terminal input for debugging. | 28 | * Terminal Input:: Recording terminal input for debugging. |
| 28 | * Terminal Output:: Recording terminal output for debugging. | 29 | * Terminal Output:: Recording terminal output for debugging. |
| @@ -1032,6 +1033,11 @@ the number of years since the year 1 B.C., and do not skip zero as | |||
| 1032 | traditional Gregorian years do; for example, the year number @minus{}37 | 1033 | traditional Gregorian years do; for example, the year number @minus{}37 |
| 1033 | represents the Gregorian year 38 B.C@. | 1034 | represents the Gregorian year 38 B.C@. |
| 1034 | 1035 | ||
| 1036 | @defun date-to-time string | ||
| 1037 | This function parses the time-string @var{string} and returns the | ||
| 1038 | corresponding time value. | ||
| 1039 | @end defun | ||
| 1040 | |||
| 1035 | @defun format-time-string format-string &optional time universal | 1041 | @defun format-time-string format-string &optional time universal |
| 1036 | This function converts @var{time} (or the current time, if @var{time} is | 1042 | This function converts @var{time} (or the current time, if @var{time} is |
| 1037 | omitted) to a string according to @var{format-string}. The argument | 1043 | omitted) to a string according to @var{format-string}. The argument |
| @@ -1146,6 +1152,12 @@ returns the resulting string, @code{format-time-string} decodes the | |||
| 1146 | string using that same coding system. | 1152 | string using that same coding system. |
| 1147 | @end defun | 1153 | @end defun |
| 1148 | 1154 | ||
| 1155 | @defun seconds-to-time seconds | ||
| 1156 | This function converts @var{seconds}, a floating point number of | ||
| 1157 | seconds since the epoch, to a time value and returns that. To perform | ||
| 1158 | the inverse conversion, use @code{float-time}. | ||
| 1159 | @end defun | ||
| 1160 | |||
| 1149 | @defun decode-time time | 1161 | @defun decode-time time |
| 1150 | This function converts a time value into calendrical information. The | 1162 | This function converts a time value into calendrical information. The |
| 1151 | return value is a list of nine elements, as follows: | 1163 | return value is a list of nine elements, as follows: |
| @@ -1217,6 +1229,45 @@ The operating system puts limits on the range of possible time values; | |||
| 1217 | if you try to encode a time that is out of range, an error results. | 1229 | if you try to encode a time that is out of range, an error results. |
| 1218 | @end defun | 1230 | @end defun |
| 1219 | 1231 | ||
| 1232 | @node Time Calculations | ||
| 1233 | @section Time Calculations | ||
| 1234 | |||
| 1235 | These functions perform calendrical computations using time values | ||
| 1236 | (the kind of list that @code{current-time} returns). | ||
| 1237 | |||
| 1238 | @defun time-less-p t1 t2 | ||
| 1239 | This returns @code{t} if time value @var{t1} is less than time value | ||
| 1240 | @var{t2}. | ||
| 1241 | @end defun | ||
| 1242 | |||
| 1243 | @defun time-subtract t1 t2 | ||
| 1244 | This returns the time difference @var{t1} @minus{} @var{t2} between | ||
| 1245 | two time values, in the same format as a time value. | ||
| 1246 | @end defun | ||
| 1247 | |||
| 1248 | @defun time-add t1 t2 | ||
| 1249 | This returns the sum of two time values, one of which ought to | ||
| 1250 | represent a time difference rather than a point in time. | ||
| 1251 | Here is how to add a number of seconds to a time value: | ||
| 1252 | |||
| 1253 | @example | ||
| 1254 | (time-add @var{time} (seconds-to-time @var{seconds})) | ||
| 1255 | @end example | ||
| 1256 | @end defun | ||
| 1257 | |||
| 1258 | @defun time-to-days time | ||
| 1259 | This function returns the number of days between the beginning of year | ||
| 1260 | 1 and @var{time}. | ||
| 1261 | @end defun | ||
| 1262 | |||
| 1263 | @defun time-to-day-in-year time | ||
| 1264 | This returns the day number within the year corresponding to @var{time}. | ||
| 1265 | @end defun | ||
| 1266 | |||
| 1267 | @defun date-leap-year-p year | ||
| 1268 | This function returns @code{t} if @var{year} is a leap year. | ||
| 1269 | @end defun | ||
| 1270 | |||
| 1220 | @node Timers | 1271 | @node Timers |
| 1221 | @section Timers for Delayed Execution | 1272 | @section Timers for Delayed Execution |
| 1222 | @cindex timer | 1273 | @cindex timer |