diff options
| author | Paul Eggert | 2016-04-12 08:47:15 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-04-12 08:49:19 -0700 |
| commit | ca509810014726cf6bee9f7e8f69bdeaf62dc146 (patch) | |
| tree | bf9e81d82e77edebcd6addc1a9bc0392425b1bdd | |
| parent | c23c965bb9d0a4bcc1b6158833ff99aa20fd53e9 (diff) | |
| download | emacs-ca509810014726cf6bee9f7e8f69bdeaf62dc146.tar.gz emacs-ca509810014726cf6bee9f7e8f69bdeaf62dc146.zip | |
Improve time zone documentation
* doc/lispref/os.texi (Time Zone Rules):
New section, mostly with material moved here from other sections.
* doc/emacs/cmdargs.texi (General Variables):
* doc/lispref/os.texi (Time Conversion, Time Parsing):
Xref new section.
* etc/NEWS, etc/PROBLEMS:
* lisp/org/org.el (org-timestamp-format):
* src/editfns.c (Fformat_time_string, Fdecode_time)
(Fencode_time, Fcurrent_time_string, Fcurrent_time_zone)
(Fset_time_zone_rule):
When documenting time zone rule strings, mention the TZ
environment variable in preference to mentioning the
sort-of-internal function set-time-zone-rule.
| -rw-r--r-- | doc/emacs/cmdargs.texi | 5 | ||||
| -rw-r--r-- | doc/lispref/os.texi | 67 | ||||
| -rw-r--r-- | etc/NEWS | 10 | ||||
| -rw-r--r-- | etc/PROBLEMS | 8 | ||||
| -rw-r--r-- | lisp/org/org.el | 2 | ||||
| -rw-r--r-- | src/editfns.c | 27 |
6 files changed, 70 insertions, 49 deletions
diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index a842cb84abd..f0f686f855c 100644 --- a/doc/emacs/cmdargs.texi +++ b/doc/emacs/cmdargs.texi | |||
| @@ -634,8 +634,9 @@ to put temporary files (@pxref{Backup}). Emacs tries to use | |||
| 634 | @env{TMP}, then @env{TEMP}, and finally @file{c:/temp}. | 634 | @env{TMP}, then @env{TEMP}, and finally @file{c:/temp}. |
| 635 | @item TZ | 635 | @item TZ |
| 636 | @vindex TZ, environment variable | 636 | @vindex TZ, environment variable |
| 637 | This specifies the current time zone and possibly also daylight | 637 | This specifies the default time zone and possibly also daylight |
| 638 | saving time information. On MS-DOS, if @env{TZ} is not set in the | 638 | saving time information. @xref{Time Zone Rules,,, elisp, The GNU |
| 639 | Emacs Lisp Reference Manual}. On MS-DOS, if @env{TZ} is not set in the | ||
| 639 | environment when Emacs starts, Emacs defines a default value as | 640 | environment when Emacs starts, Emacs defines a default value as |
| 640 | appropriate for the country code returned by DOS@. On MS-Windows, Emacs | 641 | appropriate for the country code returned by DOS@. On MS-Windows, Emacs |
| 641 | does not use @env{TZ} at all. | 642 | does not use @env{TZ} at all. |
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 88397452689..5f189b984a3 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi | |||
| @@ -19,6 +19,7 @@ terminal and the screen. | |||
| 19 | * System Environment:: Distinguish the name and kind of system. | 19 | * System Environment:: Distinguish the name and kind of system. |
| 20 | * User Identification:: Finding the name and user id of the user. | 20 | * User Identification:: Finding the name and user id of the user. |
| 21 | * Time of Day:: Getting the current time. | 21 | * Time of Day:: Getting the current time. |
| 22 | * Time Zone Rules:: Rules for time zones and daylight saving time. | ||
| 22 | * Time Conversion:: Converting a time from numeric form to | 23 | * Time Conversion:: Converting a time from numeric form to |
| 23 | calendrical data and vice versa. | 24 | calendrical data and vice versa. |
| 24 | * Time Parsing:: Converting a time from numeric form to text | 25 | * Time Parsing:: Converting a time from numeric form to text |
| @@ -1262,7 +1263,7 @@ information may some day be added at the end. | |||
| 1262 | 1263 | ||
| 1263 | The argument @var{time}, if given, specifies a time to format, | 1264 | The argument @var{time}, if given, specifies a time to format, |
| 1264 | instead of the current time. The optional argument @var{zone} | 1265 | instead of the current time. The optional argument @var{zone} |
| 1265 | defaults to the current time zone rule. | 1266 | defaults to the current time zone rule. @xref{Time Zone Rules}. |
| 1266 | 1267 | ||
| 1267 | @example | 1268 | @example |
| 1268 | @group | 1269 | @group |
| @@ -1299,26 +1300,9 @@ For example, if @var{time} is a number, @code{(time-to-seconds | |||
| 1299 | or rounding errors occur. | 1300 | or rounding errors occur. |
| 1300 | @end defun | 1301 | @end defun |
| 1301 | 1302 | ||
| 1302 | @defun current-time-zone &optional time zone | 1303 | @node Time Zone Rules |
| 1303 | @cindex time zone, current | 1304 | @section Time Zone Rules |
| 1304 | This function returns a list describing the time zone that the user is | 1305 | @cindex time zone rules |
| 1305 | in. | ||
| 1306 | |||
| 1307 | The value has the form @code{(@var{offset} @var{name})}. Here | ||
| 1308 | @var{offset} is an integer giving the number of seconds ahead of Universal Time | ||
| 1309 | (east of Greenwich). A negative value means west of Greenwich. The | ||
| 1310 | second element, @var{name}, is a string giving the name of the time | ||
| 1311 | zone. Both elements change when daylight saving time begins or ends; | ||
| 1312 | if the user has specified a time zone that does not use a seasonal time | ||
| 1313 | adjustment, then the value is constant through time. | ||
| 1314 | |||
| 1315 | If the operating system doesn't supply all the information necessary to | ||
| 1316 | compute the value, the unknown elements of the list are @code{nil}. | ||
| 1317 | |||
| 1318 | The argument @var{time}, if given, specifies a time value to | ||
| 1319 | analyze instead of the current time. The optional argument @var{zone} | ||
| 1320 | defaults to the current time zone rule. | ||
| 1321 | @end defun | ||
| 1322 | 1306 | ||
| 1323 | @vindex TZ, environment variable | 1307 | @vindex TZ, environment variable |
| 1324 | The default time zone is determined by the @env{TZ} environment | 1308 | The default time zone is determined by the @env{TZ} environment |
| @@ -1327,6 +1311,15 @@ to default to Universal Time with @code{(setenv "TZ" "UTC0")}. If | |||
| 1327 | @env{TZ} is not in the environment, Emacs uses system wall clock time, | 1311 | @env{TZ} is not in the environment, Emacs uses system wall clock time, |
| 1328 | which is a platform-dependent default time zone. | 1312 | which is a platform-dependent default time zone. |
| 1329 | 1313 | ||
| 1314 | The set of supported @env{TZ} strings is system-dependent. GNU and | ||
| 1315 | many other systems support the tzdata database, e.g., | ||
| 1316 | @samp{"America/New_York"} specifies the time zone and daylight saving | ||
| 1317 | time history for locations near New York City. GNU and most other | ||
| 1318 | systems support POSIX-style @env{TZ} strings, e.g., | ||
| 1319 | @samp{"EST+5EDT,M4.1.0/2,M10.5.0/2"} specifies the rules used in New | ||
| 1320 | York from 1987 through 2006. All systems support the string | ||
| 1321 | @samp{"UTC0"} meaning Universal Time. | ||
| 1322 | |||
| 1330 | @cindex time zone rule | 1323 | @cindex time zone rule |
| 1331 | Functions that convert to and from local time accept an optional | 1324 | Functions that convert to and from local time accept an optional |
| 1332 | @dfn{time zone rule} argument, which specifies the conversion's time | 1325 | @dfn{time zone rule} argument, which specifies the conversion's time |
| @@ -1337,6 +1330,29 @@ If it is @code{t}, the conversion uses Universal Time. If it is | |||
| 1337 | a string, the conversion uses the time zone rule equivalent to setting | 1330 | a string, the conversion uses the time zone rule equivalent to setting |
| 1338 | @env{TZ} to that string. | 1331 | @env{TZ} to that string. |
| 1339 | 1332 | ||
| 1333 | @defun current-time-zone &optional time zone | ||
| 1334 | @cindex time zone, current | ||
| 1335 | This function returns a list describing the time zone that the user is | ||
| 1336 | in. | ||
| 1337 | |||
| 1338 | The value has the form @code{(@var{offset} @var{abbr})}. Here | ||
| 1339 | @var{offset} is an integer giving the number of seconds ahead of Universal Time | ||
| 1340 | (east of Greenwich). A negative value means west of Greenwich. The | ||
| 1341 | second element, @var{abbr}, is a string giving an abbreviation for the | ||
| 1342 | time zone, e.g., @samp{"CST"} for China Standard Time or for | ||
| 1343 | U.S. Central Standard Time. Both elements can change when daylight | ||
| 1344 | saving time begins or ends; if the user has specified a time zone that | ||
| 1345 | does not use a seasonal time adjustment, then the value is constant | ||
| 1346 | through time. | ||
| 1347 | |||
| 1348 | If the operating system doesn't supply all the information necessary to | ||
| 1349 | compute the value, the unknown elements of the list are @code{nil}. | ||
| 1350 | |||
| 1351 | The argument @var{time}, if given, specifies a time value to | ||
| 1352 | analyze instead of the current time. The optional argument @var{zone} | ||
| 1353 | defaults to the current time zone rule. | ||
| 1354 | @end defun | ||
| 1355 | |||
| 1340 | @node Time Conversion | 1356 | @node Time Conversion |
| 1341 | @section Time Conversion | 1357 | @section Time Conversion |
| 1342 | @cindex calendrical information | 1358 | @cindex calendrical information |
| @@ -1361,8 +1377,8 @@ as traditional Gregorian years do; for example, the year number | |||
| 1361 | @defun decode-time &optional time zone | 1377 | @defun decode-time &optional time zone |
| 1362 | This function converts a time value into calendrical information. If | 1378 | This function converts a time value into calendrical information. If |
| 1363 | you don't specify @var{time}, it decodes the current time, and similarly | 1379 | you don't specify @var{time}, it decodes the current time, and similarly |
| 1364 | @var{zone} defaults to the current time zone rule. The return | 1380 | @var{zone} defaults to the current time zone rule. @xref{Time Zone Rules}. |
| 1365 | value is a list of nine elements, as follows: | 1381 | The return value is a list of nine elements, as follows: |
| 1366 | 1382 | ||
| 1367 | @example | 1383 | @example |
| 1368 | (@var{seconds} @var{minutes} @var{hour} @var{day} @var{month} @var{year} @var{dow} @var{dst} @var{utcoff}) | 1384 | (@var{seconds} @var{minutes} @var{hour} @var{day} @var{month} @var{year} @var{dow} @var{dst} @var{utcoff}) |
| @@ -1409,6 +1425,7 @@ to stand for years above 1900, or years above 2000, you must alter them | |||
| 1409 | yourself before you call @code{encode-time}. | 1425 | yourself before you call @code{encode-time}. |
| 1410 | 1426 | ||
| 1411 | The optional argument @var{zone} defaults to the current time zone rule. | 1427 | The optional argument @var{zone} defaults to the current time zone rule. |
| 1428 | @xref{Time Zone Rules}. | ||
| 1412 | In addition to the usual time zone rule values, it can also be a list | 1429 | In addition to the usual time zone rule values, it can also be a list |
| 1413 | (as you would get from @code{current-time-zone}) or an integer (as | 1430 | (as you would get from @code{current-time-zone}) or an integer (as |
| 1414 | from @code{decode-time}), applied without any further alteration for | 1431 | from @code{decode-time}), applied without any further alteration for |
| @@ -1452,8 +1469,8 @@ corresponding time value. | |||
| 1452 | 1469 | ||
| 1453 | This function converts @var{time} (or the current time, if | 1470 | This function converts @var{time} (or the current time, if |
| 1454 | @var{time} is omitted) to a string according to | 1471 | @var{time} is omitted) to a string according to |
| 1455 | @var{format-string}. The conversion uses the time zone rule @var{zone} | 1472 | @var{format-string}. The conversion uses the time zone rule @var{zone}, which |
| 1456 | (or the current time zone rule, if omitted). The argument | 1473 | defaults to the current time zone rule. @xref{Time Zone Rules}. The argument |
| 1457 | @var{format-string} may contain @samp{%}-sequences which say to | 1474 | @var{format-string} may contain @samp{%}-sequences which say to |
| 1458 | substitute parts of the time. Here is a table of what the | 1475 | substitute parts of the time. Here is a table of what the |
| 1459 | @samp{%}-sequences mean: | 1476 | @samp{%}-sequences mean: |
| @@ -1778,11 +1778,11 @@ quotation marks. | |||
| 1778 | *** Time conversion functions now accept an optional ZONE argument | 1778 | *** Time conversion functions now accept an optional ZONE argument |
| 1779 | that specifies the time zone rules for conversion. ZONE is omitted or | 1779 | that specifies the time zone rules for conversion. ZONE is omitted or |
| 1780 | nil for Emacs local time, t for Universal Time, 'wall' for system wall | 1780 | nil for Emacs local time, t for Universal Time, 'wall' for system wall |
| 1781 | clock time, or a string as in 'set-time-zone-rule' for a time zone | 1781 | clock time, or a string as in the TZ environment variable. The |
| 1782 | rule. The affected functions are 'current-time-string', | 1782 | affected functions are 'current-time-string', 'current-time-zone', |
| 1783 | 'current-time-zone', 'decode-time', and 'format-time-string'. The | 1783 | 'decode-time', and 'format-time-string'. The function 'encode-time', |
| 1784 | function 'encode-time', which already accepted a simple time zone rule | 1784 | which already accepted a simple time zone rule argument, has been |
| 1785 | argument, has been extended to accept all the new forms. | 1785 | extended to accept all the new forms. |
| 1786 | 1786 | ||
| 1787 | *** Incompatible change in the third argument of 'format-time-string'. | 1787 | *** Incompatible change in the third argument of 'format-time-string'. |
| 1788 | Previously, any non-nil argument was interpreted as specifying Universal Time. | 1788 | Previously, any non-nil argument was interpreted as specifying Universal Time. |
diff --git a/etc/PROBLEMS b/etc/PROBLEMS index b0c21ee25dd..be9400bf264 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS | |||
| @@ -2220,11 +2220,11 @@ month names with consistent widths for some locales on some versions | |||
| 2220 | of Windows. This is caused by a deficiency in the underlying system | 2220 | of Windows. This is caused by a deficiency in the underlying system |
| 2221 | library function. | 2221 | library function. |
| 2222 | 2222 | ||
| 2223 | ** Problems with set-time-zone-rule function | 2223 | ** Non-US time zones. |
| 2224 | 2224 | ||
| 2225 | The function set-time-zone-rule gives incorrect results for many | 2225 | Many non-US time zones are implemented incorrectly. This is due to |
| 2226 | non-US timezones. This is due to over-simplistic handling of | 2226 | over-simplistic handling of daylight savings switchovers by the |
| 2227 | daylight savings switchovers by the Windows libraries. | 2227 | Windows libraries. |
| 2228 | 2228 | ||
| 2229 | ** Files larger than 4GB report wrong size in a 32-bit Windows build | 2229 | ** Files larger than 4GB report wrong size in a 32-bit Windows build |
| 2230 | 2230 | ||
diff --git a/lisp/org/org.el b/lisp/org/org.el index d2b48a64e45..231daa9a6a7 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el | |||
| @@ -22674,7 +22674,7 @@ time-range, if possible. | |||
| 22674 | 22674 | ||
| 22675 | The optional ZONE is omitted or nil for Emacs local time, t for | 22675 | The optional ZONE is omitted or nil for Emacs local time, t for |
| 22676 | Universal Time, `wall' for system wall clock time, or a string as in | 22676 | Universal Time, `wall' for system wall clock time, or a string as in |
| 22677 | `set-time-zone-rule' for a time zone rule." | 22677 | the TZ environment variable." |
| 22678 | (format-time-string | 22678 | (format-time-string |
| 22679 | format | 22679 | format |
| 22680 | (apply 'encode-time | 22680 | (apply 'encode-time |
diff --git a/src/editfns.c b/src/editfns.c index 2ac0537eddb..94b949583ad 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -1969,10 +1969,10 @@ DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, | |||
| 1969 | doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted. | 1969 | doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted. |
| 1970 | TIME is specified as (HIGH LOW USEC PSEC), as returned by | 1970 | TIME is specified as (HIGH LOW USEC PSEC), as returned by |
| 1971 | `current-time' or `file-attributes'. The obsolete form (HIGH . LOW) | 1971 | `current-time' or `file-attributes'. The obsolete form (HIGH . LOW) |
| 1972 | is also still accepted. | 1972 | is also still accepted. The optional ZONE is omitted or nil for Emacs |
| 1973 | The optional ZONE is omitted or nil for Emacs local time, t for | 1973 | local time, t for Universal Time, `wall' for system wall clock time, |
| 1974 | Universal Time, `wall' for system wall clock time, or a string as in | 1974 | or a string as in the TZ environment variable. |
| 1975 | `set-time-zone-rule' for a time zone rule. | 1975 | |
| 1976 | The value is a copy of FORMAT-STRING, but with certain constructs replaced | 1976 | The value is a copy of FORMAT-STRING, but with certain constructs replaced |
| 1977 | by text that describes the specified date and time in TIME: | 1977 | by text that describes the specified date and time in TIME: |
| 1978 | 1978 | ||
| @@ -2086,7 +2086,7 @@ as from `current-time' and `file-attributes', or nil to use the | |||
| 2086 | current time. The obsolete form (HIGH . LOW) is also still accepted. | 2086 | current time. The obsolete form (HIGH . LOW) is also still accepted. |
| 2087 | The optional ZONE is omitted or nil for Emacs local time, t for | 2087 | The optional ZONE is omitted or nil for Emacs local time, t for |
| 2088 | Universal Time, `wall' for system wall clock time, or a string as in | 2088 | Universal Time, `wall' for system wall clock time, or a string as in |
| 2089 | `set-time-zone-rule' for a time zone rule. | 2089 | the TZ environment variable. |
| 2090 | 2090 | ||
| 2091 | The list has the following nine members: SEC is an integer between 0 | 2091 | The list has the following nine members: SEC is an integer between 0 |
| 2092 | and 60; SEC is 60 for a leap second, which only some operating systems | 2092 | and 60; SEC is 60 for a leap second, which only some operating systems |
| @@ -2151,9 +2151,9 @@ DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, | |||
| 2151 | This is the reverse operation of `decode-time', which see. | 2151 | This is the reverse operation of `decode-time', which see. |
| 2152 | The optional ZONE is omitted or nil for Emacs local time, t for | 2152 | The optional ZONE is omitted or nil for Emacs local time, t for |
| 2153 | Universal Time, `wall' for system wall clock time, or a string as in | 2153 | Universal Time, `wall' for system wall clock time, or a string as in |
| 2154 | `set-time-zone-rule' for a time zone rule. It can also be a list (as | 2154 | the TZ environment variable. It can also be a list (as from |
| 2155 | from `current-time-zone') or an integer (as from `decode-time') | 2155 | `current-time-zone') or an integer (as from `decode-time') applied |
| 2156 | applied without consideration for daylight saving time. | 2156 | without consideration for daylight saving time. |
| 2157 | 2157 | ||
| 2158 | You can pass more than 7 arguments; then the first six arguments | 2158 | You can pass more than 7 arguments; then the first six arguments |
| 2159 | are used as SECOND through YEAR, and the *last* argument is used as ZONE. | 2159 | are used as SECOND through YEAR, and the *last* argument is used as ZONE. |
| @@ -2213,7 +2213,7 @@ but this is considered obsolete. | |||
| 2213 | 2213 | ||
| 2214 | The optional ZONE is omitted or nil for Emacs local time, t for | 2214 | The optional ZONE is omitted or nil for Emacs local time, t for |
| 2215 | Universal Time, `wall' for system wall clock time, or a string as in | 2215 | Universal Time, `wall' for system wall clock time, or a string as in |
| 2216 | `set-time-zone-rule' for a time zone rule. */) | 2216 | the TZ environment variable. */) |
| 2217 | (Lisp_Object specified_time, Lisp_Object zone) | 2217 | (Lisp_Object specified_time, Lisp_Object zone) |
| 2218 | { | 2218 | { |
| 2219 | time_t value = lisp_seconds_argument (specified_time); | 2219 | time_t value = lisp_seconds_argument (specified_time); |
| @@ -2290,7 +2290,7 @@ instead of using the current time. The argument should have the form | |||
| 2290 | `current-time' and from `file-attributes'. SPECIFIED-TIME can also | 2290 | `current-time' and from `file-attributes'. SPECIFIED-TIME can also |
| 2291 | have the form (HIGH . LOW), but this is considered obsolete. | 2291 | have the form (HIGH . LOW), but this is considered obsolete. |
| 2292 | Optional second arg ZONE is omitted or nil for the local time zone, or | 2292 | Optional second arg ZONE is omitted or nil for the local time zone, or |
| 2293 | a string as in `set-time-zone-rule'. | 2293 | a string as in the TZ environment variable. |
| 2294 | 2294 | ||
| 2295 | Some operating systems cannot provide all this information to Emacs; | 2295 | Some operating systems cannot provide all this information to Emacs; |
| 2296 | in this case, `current-time-zone' returns a list containing nil for | 2296 | in this case, `current-time-zone' returns a list containing nil for |
| @@ -2331,8 +2331,11 @@ the data it can't find. */) | |||
| 2331 | 2331 | ||
| 2332 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, | 2332 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, |
| 2333 | doc: /* Set the Emacs local time zone using TZ, a string specifying a time zone rule. | 2333 | doc: /* Set the Emacs local time zone using TZ, a string specifying a time zone rule. |
| 2334 | If TZ is nil or `wall', use system wall clock time. If TZ is t, use | 2334 | |
| 2335 | Universal Time. If TZ is an integer, treat it as in `encode-time'. | 2335 | If TZ is nil or `wall', use system wall clock time; this differs from |
| 2336 | the usual Emacs convention where nil means current local time. If TZ | ||
| 2337 | is t, use Universal Time. If TZ is an integer, treat it as in | ||
| 2338 | `encode-time'. | ||
| 2336 | 2339 | ||
| 2337 | Instead of calling this function, you typically want something else. | 2340 | Instead of calling this function, you typically want something else. |
| 2338 | To temporarily use a different time zone rule for just one invocation | 2341 | To temporarily use a different time zone rule for just one invocation |