aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2016-04-12 08:47:15 -0700
committerPaul Eggert2016-04-12 08:49:19 -0700
commitca509810014726cf6bee9f7e8f69bdeaf62dc146 (patch)
treebf9e81d82e77edebcd6addc1a9bc0392425b1bdd
parentc23c965bb9d0a4bcc1b6158833ff99aa20fd53e9 (diff)
downloademacs-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.texi5
-rw-r--r--doc/lispref/os.texi67
-rw-r--r--etc/NEWS10
-rw-r--r--etc/PROBLEMS8
-rw-r--r--lisp/org/org.el2
-rw-r--r--src/editfns.c27
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
637This specifies the current time zone and possibly also daylight 637This specifies the default time zone and possibly also daylight
638saving time information. On MS-DOS, if @env{TZ} is not set in the 638saving time information. @xref{Time Zone Rules,,, elisp, The GNU
639Emacs Lisp Reference Manual}. On MS-DOS, if @env{TZ} is not set in the
639environment when Emacs starts, Emacs defines a default value as 640environment when Emacs starts, Emacs defines a default value as
640appropriate for the country code returned by DOS@. On MS-Windows, Emacs 641appropriate for the country code returned by DOS@. On MS-Windows, Emacs
641does not use @env{TZ} at all. 642does 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
1263The argument @var{time}, if given, specifies a time to format, 1264The argument @var{time}, if given, specifies a time to format,
1264instead of the current time. The optional argument @var{zone} 1265instead of the current time. The optional argument @var{zone}
1265defaults to the current time zone rule. 1266defaults 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
1299or rounding errors occur. 1300or 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
1304This function returns a list describing the time zone that the user is 1305@cindex time zone rules
1305in.
1306
1307The 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
1310second element, @var{name}, is a string giving the name of the time
1311zone. Both elements change when daylight saving time begins or ends;
1312if the user has specified a time zone that does not use a seasonal time
1313adjustment, then the value is constant through time.
1314
1315If the operating system doesn't supply all the information necessary to
1316compute the value, the unknown elements of the list are @code{nil}.
1317
1318The argument @var{time}, if given, specifies a time value to
1319analyze instead of the current time. The optional argument @var{zone}
1320defaults to the current time zone rule.
1321@end defun
1322 1306
1323@vindex TZ, environment variable 1307@vindex TZ, environment variable
1324The default time zone is determined by the @env{TZ} environment 1308The 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,
1328which is a platform-dependent default time zone. 1312which is a platform-dependent default time zone.
1329 1313
1314The set of supported @env{TZ} strings is system-dependent. GNU and
1315many other systems support the tzdata database, e.g.,
1316@samp{"America/New_York"} specifies the time zone and daylight saving
1317time history for locations near New York City. GNU and most other
1318systems 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
1320York 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
1331Functions that convert to and from local time accept an optional 1324Functions 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
1337a string, the conversion uses the time zone rule equivalent to setting 1330a 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
1335This function returns a list describing the time zone that the user is
1336in.
1337
1338The 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
1341second element, @var{abbr}, is a string giving an abbreviation for the
1342time zone, e.g., @samp{"CST"} for China Standard Time or for
1343U.S. Central Standard Time. Both elements can change when daylight
1344saving time begins or ends; if the user has specified a time zone that
1345does not use a seasonal time adjustment, then the value is constant
1346through time.
1347
1348If the operating system doesn't supply all the information necessary to
1349compute the value, the unknown elements of the list are @code{nil}.
1350
1351The argument @var{time}, if given, specifies a time value to
1352analyze instead of the current time. The optional argument @var{zone}
1353defaults 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
1362This function converts a time value into calendrical information. If 1378This function converts a time value into calendrical information. If
1363you don't specify @var{time}, it decodes the current time, and similarly 1379you 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}.
1365value is a list of nine elements, as follows: 1381The 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
1409yourself before you call @code{encode-time}. 1425yourself before you call @code{encode-time}.
1410 1426
1411The optional argument @var{zone} defaults to the current time zone rule. 1427The optional argument @var{zone} defaults to the current time zone rule.
1428@xref{Time Zone Rules}.
1412In addition to the usual time zone rule values, it can also be a list 1429In 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
1414from @code{decode-time}), applied without any further alteration for 1431from @code{decode-time}), applied without any further alteration for
@@ -1452,8 +1469,8 @@ corresponding time value.
1452 1469
1453This function converts @var{time} (or the current time, if 1470This 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 1473defaults 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
1458substitute parts of the time. Here is a table of what the 1475substitute parts of the time. Here is a table of what the
1459@samp{%}-sequences mean: 1476@samp{%}-sequences mean:
diff --git a/etc/NEWS b/etc/NEWS
index fe7df96ecea..bae42af6d6d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
1779that specifies the time zone rules for conversion. ZONE is omitted or 1779that specifies the time zone rules for conversion. ZONE is omitted or
1780nil for Emacs local time, t for Universal Time, 'wall' for system wall 1780nil for Emacs local time, t for Universal Time, 'wall' for system wall
1781clock time, or a string as in 'set-time-zone-rule' for a time zone 1781clock time, or a string as in the TZ environment variable. The
1782rule. The affected functions are 'current-time-string', 1782affected 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',
1784function 'encode-time', which already accepted a simple time zone rule 1784which already accepted a simple time zone rule argument, has been
1785argument, has been extended to accept all the new forms. 1785extended 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'.
1788Previously, any non-nil argument was interpreted as specifying Universal Time. 1788Previously, 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
2220of Windows. This is caused by a deficiency in the underlying system 2220of Windows. This is caused by a deficiency in the underlying system
2221library function. 2221library function.
2222 2222
2223** Problems with set-time-zone-rule function 2223** Non-US time zones.
2224 2224
2225The function set-time-zone-rule gives incorrect results for many 2225Many non-US time zones are implemented incorrectly. This is due to
2226non-US timezones. This is due to over-simplistic handling of 2226over-simplistic handling of daylight savings switchovers by the
2227daylight savings switchovers by the Windows libraries. 2227Windows 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
22675The optional ZONE is omitted or nil for Emacs local time, t for 22675The optional ZONE is omitted or nil for Emacs local time, t for
22676Universal Time, `wall' for system wall clock time, or a string as in 22676Universal Time, `wall' for system wall clock time, or a string as in
22677`set-time-zone-rule' for a time zone rule." 22677the 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.
1970TIME is specified as (HIGH LOW USEC PSEC), as returned by 1970TIME 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)
1972is also still accepted. 1972is also still accepted. The optional ZONE is omitted or nil for Emacs
1973The optional ZONE is omitted or nil for Emacs local time, t for 1973local time, t for Universal Time, `wall' for system wall clock time,
1974Universal Time, `wall' for system wall clock time, or a string as in 1974or a string as in the TZ environment variable.
1975`set-time-zone-rule' for a time zone rule. 1975
1976The value is a copy of FORMAT-STRING, but with certain constructs replaced 1976The value is a copy of FORMAT-STRING, but with certain constructs replaced
1977by text that describes the specified date and time in TIME: 1977by 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
2086current time. The obsolete form (HIGH . LOW) is also still accepted. 2086current time. The obsolete form (HIGH . LOW) is also still accepted.
2087The optional ZONE is omitted or nil for Emacs local time, t for 2087The optional ZONE is omitted or nil for Emacs local time, t for
2088Universal Time, `wall' for system wall clock time, or a string as in 2088Universal Time, `wall' for system wall clock time, or a string as in
2089`set-time-zone-rule' for a time zone rule. 2089the TZ environment variable.
2090 2090
2091The list has the following nine members: SEC is an integer between 0 2091The list has the following nine members: SEC is an integer between 0
2092and 60; SEC is 60 for a leap second, which only some operating systems 2092and 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,
2151This is the reverse operation of `decode-time', which see. 2151This is the reverse operation of `decode-time', which see.
2152The optional ZONE is omitted or nil for Emacs local time, t for 2152The optional ZONE is omitted or nil for Emacs local time, t for
2153Universal Time, `wall' for system wall clock time, or a string as in 2153Universal 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 2154the TZ environment variable. It can also be a list (as from
2155from `current-time-zone') or an integer (as from `decode-time') 2155`current-time-zone') or an integer (as from `decode-time') applied
2156applied without consideration for daylight saving time. 2156without consideration for daylight saving time.
2157 2157
2158You can pass more than 7 arguments; then the first six arguments 2158You can pass more than 7 arguments; then the first six arguments
2159are used as SECOND through YEAR, and the *last* argument is used as ZONE. 2159are used as SECOND through YEAR, and the *last* argument is used as ZONE.
@@ -2213,7 +2213,7 @@ but this is considered obsolete.
2213 2213
2214The optional ZONE is omitted or nil for Emacs local time, t for 2214The optional ZONE is omitted or nil for Emacs local time, t for
2215Universal Time, `wall' for system wall clock time, or a string as in 2215Universal Time, `wall' for system wall clock time, or a string as in
2216`set-time-zone-rule' for a time zone rule. */) 2216the 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
2291have the form (HIGH . LOW), but this is considered obsolete. 2291have the form (HIGH . LOW), but this is considered obsolete.
2292Optional second arg ZONE is omitted or nil for the local time zone, or 2292Optional second arg ZONE is omitted or nil for the local time zone, or
2293a string as in `set-time-zone-rule'. 2293a string as in the TZ environment variable.
2294 2294
2295Some operating systems cannot provide all this information to Emacs; 2295Some operating systems cannot provide all this information to Emacs;
2296in this case, `current-time-zone' returns a list containing nil for 2296in this case, `current-time-zone' returns a list containing nil for
@@ -2331,8 +2331,11 @@ the data it can't find. */)
2331 2331
2332DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, 2332DEFUN ("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.
2334If TZ is nil or `wall', use system wall clock time. If TZ is t, use 2334
2335Universal Time. If TZ is an integer, treat it as in `encode-time'. 2335If TZ is nil or `wall', use system wall clock time; this differs from
2336the usual Emacs convention where nil means current local time. If TZ
2337is t, use Universal Time. If TZ is an integer, treat it as in
2338`encode-time'.
2336 2339
2337Instead of calling this function, you typically want something else. 2340Instead of calling this function, you typically want something else.
2338To temporarily use a different time zone rule for just one invocation 2341To temporarily use a different time zone rule for just one invocation