aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-08-11 19:47:10 +0000
committerRichard M. Stallman2005-08-11 19:47:10 +0000
commit4bdbd317857c6c49ae1e87f5e1ba91a7e120a6d0 (patch)
tree1ad11b6dd41a59c5b7a1dd9ecabf002cc98f1003
parent088767cbda69d1d0d52297fafe145c36d8b006a2 (diff)
downloademacs-4bdbd317857c6c49ae1e87f5e1ba91a7e120a6d0.tar.gz
emacs-4bdbd317857c6c49ae1e87f5e1ba91a7e120a6d0.zip
(Time Parsing): New node split out of Time Conversion.
-rw-r--r--lispref/os.texi179
1 files changed, 93 insertions, 86 deletions
diff --git a/lispref/os.texi b/lispref/os.texi
index 52108907e9c..3f00ae99cf0 100644
--- a/lispref/os.texi
+++ b/lispref/os.texi
@@ -21,8 +21,10 @@ pertaining to the terminal and the screen.
21* System Environment:: Distinguish the name and kind of system. 21* System Environment:: Distinguish the name and kind of system.
22* User Identification:: Finding the name and user id of the user. 22* User Identification:: Finding the name and user id of the user.
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
25 to calendrical data (or vice versa). 25 to calendrical data, and vice versa).
26* Time Parsing:: Converting a time from numeric form to text
27 and vice versa.
26* Processor Run Time:: Getting the run time used by Emacs. 28* Processor Run Time:: Getting the run time used by Emacs.
27* Time Calculations:: Adding, subtracting, comparing times, etc. 29* Time Calculations:: Adding, subtracting, comparing times, etc.
28* Timers:: Setting a timer to call a function at a certain time. 30* Timers:: Setting a timer to call a function at a certain time.
@@ -1071,22 +1073,102 @@ exact. Do not use this function if precise time stamps are required.
1071@section Time Conversion 1073@section Time Conversion
1072 1074
1073 These functions convert time values (lists of two or three integers) 1075 These functions convert time values (lists of two or three integers)
1074to strings or to calendrical information. There is also a function to 1076to calendrical information and vice versa. You can get time values
1075convert calendrical information to a time value. You can get time 1077from the functions @code{current-time} (@pxref{Time of Day}) and
1076values from the functions @code{current-time} (@pxref{Time of Day}) and
1077@code{file-attributes} (@pxref{Definition of file-attributes}). 1078@code{file-attributes} (@pxref{Definition of file-attributes}).
1078 1079
1079Many operating systems are limited to time values that contain 32 bits 1080 Many operating systems are limited to time values that contain 32 bits
1080of information; these systems typically handle only the times from 1081of information; these systems typically handle only the times from
10811901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC. However, some 10821901-12-13 20:45:52 UTC through 2038-01-19 03:14:07 UTC. However, some
1082operating systems have larger time values, and can represent times far 1083operating systems have larger time values, and can represent times far
1083in the past or future. 1084in the past or future.
1084 1085
1085Time conversion functions always use the Gregorian calendar, even for 1086 Time conversion functions always use the Gregorian calendar, even
1086dates before the Gregorian calendar was introduced. Year numbers count 1087for dates before the Gregorian calendar was introduced. Year numbers
1087the number of years since the year 1 B.C., and do not skip zero as 1088count the number of years since the year 1 B.C., and do not skip zero
1088traditional Gregorian years do; for example, the year number @minus{}37 1089as traditional Gregorian years do; for example, the year number
1089represents the Gregorian year 38 B.C@. 1090@minus{}37 represents the Gregorian year 38 B.C@.
1091
1092@defun decode-time &optional time
1093This function converts a time value into calendrical information. If
1094you don't specify @var{time}, it decodes the current time. The return
1095value is a list of nine elements, as follows:
1096
1097@example
1098(@var{seconds} @var{minutes} @var{hour} @var{day} @var{month} @var{year} @var{dow} @var{dst} @var{zone})
1099@end example
1100
1101Here is what the elements mean:
1102
1103@table @var
1104@item seconds
1105The number of seconds past the minute, as an integer between 0 and 59.
1106On some operating systems, this is 60 for leap seconds.
1107@item minutes
1108The number of minutes past the hour, as an integer between 0 and 59.
1109@item hour
1110The hour of the day, as an integer between 0 and 23.
1111@item day
1112The day of the month, as an integer between 1 and 31.
1113@item month
1114The month of the year, as an integer between 1 and 12.
1115@item year
1116The year, an integer typically greater than 1900.
1117@item dow
1118The day of week, as an integer between 0 and 6, where 0 stands for
1119Sunday.
1120@item dst
1121@code{t} if daylight savings time is effect, otherwise @code{nil}.
1122@item zone
1123An integer indicating the time zone, as the number of seconds east of
1124Greenwich.
1125@end table
1126
1127@strong{Common Lisp Note:} Common Lisp has different meanings for
1128@var{dow} and @var{zone}.
1129@end defun
1130
1131@defun encode-time seconds minutes hour day month year &optional zone
1132This function is the inverse of @code{decode-time}. It converts seven
1133items of calendrical data into a time value. For the meanings of the
1134arguments, see the table above under @code{decode-time}.
1135
1136Year numbers less than 100 are not treated specially. If you want them
1137to stand for years above 1900, or years above 2000, you must alter them
1138yourself before you call @code{encode-time}.
1139
1140The optional argument @var{zone} defaults to the current time zone and
1141its daylight savings time rules. If specified, it can be either a list
1142(as you would get from @code{current-time-zone}), a string as in the
1143@code{TZ} environment variable, @code{t} for Universal Time, or an
1144integer (as you would get from @code{decode-time}). The specified
1145zone is used without any further alteration for daylight savings time.
1146
1147If you pass more than seven arguments to @code{encode-time}, the first
1148six are used as @var{seconds} through @var{year}, the last argument is
1149used as @var{zone}, and the arguments in between are ignored. This
1150feature makes it possible to use the elements of a list returned by
1151@code{decode-time} as the arguments to @code{encode-time}, like this:
1152
1153@example
1154(apply 'encode-time (decode-time @dots{}))
1155@end example
1156
1157You can perform simple date arithmetic by using out-of-range values for
1158the @var{seconds}, @var{minutes}, @var{hour}, @var{day}, and @var{month}
1159arguments; for example, day 0 means the day preceding the given month.
1160
1161The operating system puts limits on the range of possible time values;
1162if you try to encode a time that is out of range, an error results.
1163For instance, years before 1970 do not work on some systems;
1164on others, years as early as 1901 do work.
1165@end defun
1166
1167@node Time Parsing
1168@section Parsing and Formatting Times
1169
1170 These functions convert time values (lists of two or three integers)
1171to text in a string, and vice versa.
1090 1172
1091@defun date-to-time string 1173@defun date-to-time string
1092This function parses the time-string @var{string} and returns the 1174This function parses the time-string @var{string} and returns the
@@ -1213,81 +1295,6 @@ seconds since the epoch, to a time value and returns that. To perform
1213the inverse conversion, use @code{float-time}. 1295the inverse conversion, use @code{float-time}.
1214@end defun 1296@end defun
1215 1297
1216@defun decode-time &optional time
1217This function converts a time value into calendrical information. If
1218you don't specify @var{time}, it decodes the current time. The return
1219value is a list of nine elements, as follows:
1220
1221@example
1222(@var{seconds} @var{minutes} @var{hour} @var{day} @var{month} @var{year} @var{dow} @var{dst} @var{zone})
1223@end example
1224
1225Here is what the elements mean:
1226
1227@table @var
1228@item seconds
1229The number of seconds past the minute, as an integer between 0 and 59.
1230On some operating systems, this is 60 for leap seconds.
1231@item minutes
1232The number of minutes past the hour, as an integer between 0 and 59.
1233@item hour
1234The hour of the day, as an integer between 0 and 23.
1235@item day
1236The day of the month, as an integer between 1 and 31.
1237@item month
1238The month of the year, as an integer between 1 and 12.
1239@item year
1240The year, an integer typically greater than 1900.
1241@item dow
1242The day of week, as an integer between 0 and 6, where 0 stands for
1243Sunday.
1244@item dst
1245@code{t} if daylight savings time is effect, otherwise @code{nil}.
1246@item zone
1247An integer indicating the time zone, as the number of seconds east of
1248Greenwich.
1249@end table
1250
1251@strong{Common Lisp Note:} Common Lisp has different meanings for
1252@var{dow} and @var{zone}.
1253@end defun
1254
1255@defun encode-time seconds minutes hour day month year &optional zone
1256This function is the inverse of @code{decode-time}. It converts seven
1257items of calendrical data into a time value. For the meanings of the
1258arguments, see the table above under @code{decode-time}.
1259
1260Year numbers less than 100 are not treated specially. If you want them
1261to stand for years above 1900, or years above 2000, you must alter them
1262yourself before you call @code{encode-time}.
1263
1264The optional argument @var{zone} defaults to the current time zone and
1265its daylight savings time rules. If specified, it can be either a list
1266(as you would get from @code{current-time-zone}), a string as in the
1267@code{TZ} environment variable, @code{t} for Universal Time, or an
1268integer (as you would get from @code{decode-time}). The specified
1269zone is used without any further alteration for daylight savings time.
1270
1271If you pass more than seven arguments to @code{encode-time}, the first
1272six are used as @var{seconds} through @var{year}, the last argument is
1273used as @var{zone}, and the arguments in between are ignored. This
1274feature makes it possible to use the elements of a list returned by
1275@code{decode-time} as the arguments to @code{encode-time}, like this:
1276
1277@example
1278(apply 'encode-time (decode-time @dots{}))
1279@end example
1280
1281You can perform simple date arithmetic by using out-of-range values for
1282the @var{seconds}, @var{minutes}, @var{hour}, @var{day}, and @var{month}
1283arguments; for example, day 0 means the day preceding the given month.
1284
1285The operating system puts limits on the range of possible time values;
1286if you try to encode a time that is out of range, an error results.
1287For instance, years before 1970 do not work on some systems;
1288on others, years as early as 1901 do work.
1289@end defun
1290
1291@node Processor Run Time 1298@node Processor Run Time
1292@section Processor Run time 1299@section Processor Run time
1293 1300