commit 7d835d8e792664e201ec50ba5f0a260d91e1fff5 (HEAD, refs/remotes/origin/master) Author: Paul Eggert Date: Tue Apr 12 18:06:31 2016 -0700 Avoid now-obsolete function gmm-format-time-string * lisp/gnus/message.el (message-insert-formatted-citation-line): Use format-time-string instead of obsolete function gmm-format-time-string. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 32d740b..3b2cf67 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3976,7 +3976,7 @@ See `message-citation-line-format'." (>= i ?a))) (push i lst) (push (condition-case nil - (gmm-format-time-string (format "%%%c" i) time tz) + (format-time-string (format "%%%c" i) time tz) (error (format ">%c<" i))) lst)) (setq i (1+ i))) commit fdb1ba144ca61185e6457f092f38f59dd9bbe6a0 Author: Paul Eggert Date: Tue Apr 12 09:19:11 2016 -0700 Support OFFSET and (OFFSET ABBR) time zone rules This simplifies Gnus and VC time zone support, by letting them feed the output of ‘current-time-zone’ and ‘decode time’ to primitives that accept time zone arguments. * doc/lispref/os.texi (Time Zone Rules, Time Conversion): * etc/NEWS: * lisp/gnus/message.el (message-insert-formatted-citation-line): * lisp/org/org.el (org-timestamp-format): * src/editfns.c (Fformat_time_string, Fdecode_time): (Fcurrent_time_string, Fcurrent_time_zone, Fset_time_zone_rule): Document new behavior. * lisp/gnus/gmm-utils.el (gmm-format-time-string): * lisp/vc/add-log.el (add-log-iso8601-time-zone): Mark as obsolete, as it is now just an alias or narrow wrapper around format-time-string. * src/editfns.c (tzlookup): Also support integer OFFSET and list (OFFSET ABBR) as time zone rules. (Fencode_time): No longer need a special case for a cons ZONE. (Fcurrent_time_zone): If the time zone string is missing, compute it the same way the other new code does. diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 6e0edec..becb691 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -1325,7 +1325,12 @@ omitted or @code{nil}, the conversion uses Emacs's default time zone. If it is @code{t}, the conversion uses Universal Time. If it is @code{wall}, the conversion uses the system wall clock time. If it is a string, the conversion uses the time zone rule equivalent to setting -@env{TZ} to that string. +@env{TZ} to that string. If it is an integer @var{offset}, the +conversion uses a fixed time zone with the given offset and a numeric +abbreviation. If it is a list (@var{offset} @var{abbr}), where +@var{offset} is an integer number of seconds east of Universal Time +and @var{abbr} is a string, the conversion uses a fixed time zone with +the given offset and abbreviation. @defun current-time-zone &optional time zone @cindex time zone, current @@ -1423,10 +1428,6 @@ yourself before you call @code{encode-time}. The optional argument @var{zone} defaults to the current time zone rule. @xref{Time Zone Rules}. -In addition to the usual time zone rule values, it can also be a list -(as you would get from @code{current-time-zone}) or an integer (as -from @code{decode-time}), applied without any further alteration for -daylight saving time. If you pass more than seven arguments to @code{encode-time}, the first six are used as @var{seconds} through @var{year}, the last argument is diff --git a/etc/NEWS b/etc/NEWS index 00f5aad..5ebff62 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -228,6 +228,14 @@ two objects are 'eq' ('eql'), then the result of 'sxhash-eq' consistency with the new functions. For compatibility, 'sxhash' remains as an alias to 'sxhash-equal'. ++++ +** Time conversion functions that accept a time zone rule argument now +allow it to be OFFSET or a list (OFFSET ABBR), where the integer +OFFSET is a count of seconds east of Universal Time, and the string +ABBR is a time zone abbreviation. The affected functions are +'current-time-string', 'current-time-zone', 'decode-time', +'format-time-string', and 'set-time-zone-rule'. + * Changes in Emacs 25.2 on Non-Free Operating Systems diff --git a/lisp/gnus/gmm-utils.el b/lisp/gnus/gmm-utils.el index f6455cf..7aa5279 100644 --- a/lisp/gnus/gmm-utils.el +++ b/lisp/gnus/gmm-utils.el @@ -256,37 +256,8 @@ If mode is nil, use `major-mode' of the current buffer." (string-match "^\\(.+\\)-mode$" mode) (match-string 1 mode)))))) -(defun gmm-format-time-string (format-string &optional time tz) - "Use FORMAT-STRING to format the time TIME, or now if omitted. -The optional TZ specifies the time zone in a number of seconds; any -other non-nil value will be treated as 0. Note that both the format -specifiers `%Z' and `%z' will be replaced with a numeric form. " -;; FIXME: is there a smart way to replace %Z with a time zone name? - (if (and (numberp tz) (not (zerop tz))) - (let ((st 0) - (case-fold-search t) - ls nd rest) - (setq time (if time - (copy-sequence time) - (current-time))) - (if (>= (setq ls (- (cadr time) (car (current-time-zone)) (- tz))) 0) - (setcar (cdr time) ls) - (setcar (cdr time) (+ ls 65536)) - (setcar time (1- (car time)))) - (setq tz (format "%s%02d%02d" - (if (>= tz 0) "+" "-") - (/ (abs tz) 3600) - (/ (% (abs tz) 3600) 60))) - (while (string-match "%+z" format-string st) - (if (zerop (% (- (setq nd (match-end 0)) (match-beginning 0)) 2)) - (progn - (push (substring format-string st (- nd 2)) rest) - (push tz rest)) - (push (substring format-string st nd) rest)) - (setq st nd)) - (push (substring format-string st) rest) - (format-time-string (apply 'concat (nreverse rest)) time)) - (format-time-string format-string time t))) +(define-obsolete-function-alias 'gmm-format-time-string 'format-time-string + "25.2") (provide 'gmm-utils) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 14d8d30..32d740b 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3879,8 +3879,13 @@ This function uses `mail-citation-hook' if that is non-nil." (defun message-insert-formatted-citation-line (&optional from date tz) "Function that inserts a formatted citation line. The optional FROM, and DATE are strings containing the contents of -the From header and the Date header respectively. The optional TZ -is a number of seconds, overrides the time zone of DATE. +the From header and the Date header respectively. + +The optional TZ is omitted or nil for Emacs local time, t for +Universal Time, `wall' for system wall clock time, or a string as +in the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') +applied without consideration for daylight saving time. See `message-citation-line-format'." ;; The optional args are for testing/debugging. They will disappear later. diff --git a/lisp/org/org.el b/lisp/org/org.el index 231daa9..3abf627 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -22673,8 +22673,10 @@ When optional argument END is non-nil, use end of date-range or time-range, if possible. The optional ZONE is omitted or nil for Emacs local time, t for -Universal Time, `wall' for system wall clock time, or a string as in -the TZ environment variable." +Universal Time, `wall' for system wall clock time, or a string as +in the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') +applied without consideration for daylight saving time." (format-time-string format (apply 'encode-time diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index 58a4e77..9076d83 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -590,25 +590,14 @@ If a string, interpret as the ZONE argument of `format-time-string'.") (lambda (x) (or (booleanp x) (stringp x)))) (defun add-log-iso8601-time-zone (&optional time zone) - (let* ((utc-offset (or (car (current-time-zone time zone)) 0)) - (sign (if (< utc-offset 0) ?- ?+)) - (sec (abs utc-offset)) - (ss (% sec 60)) - (min (/ sec 60)) - (mm (% min 60)) - (hh (/ min 60))) - (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d") - ((not (zerop mm)) "%c%02d:%02d") - (t "%c%02d")) - sign hh mm ss))) + (declare (obsolete nil "25.2")) + (format-time-string "%:::z" time zone)) (defvar add-log-iso8601-with-time-zone nil) (defun add-log-iso8601-time-string (&optional time zone) - (let ((date (format-time-string "%Y-%m-%d" time zone))) - (if add-log-iso8601-with-time-zone - (concat date " " (add-log-iso8601-time-zone time zone)) - date))) + (format-time-string + (if add-log-iso8601-with-time-zone "%Y-%m-%d %:::z" "%Y-%m-%d") time zone)) (defun change-log-name () "Return (system-dependent) default name for a change log file." diff --git a/src/editfns.c b/src/editfns.c index 70285e6..48f2a8d 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -146,8 +146,6 @@ xtzfree (timezone_t tz) static timezone_t tzlookup (Lisp_Object zone, bool settz) { - static char const tzbuf_format[] = "XXX%s%"pI"d:%02d:%02d"; - char tzbuf[sizeof tzbuf_format + INT_STRLEN_BOUND (EMACS_INT)]; char const *zone_string; timezone_t new_tz; @@ -160,16 +158,53 @@ tzlookup (Lisp_Object zone, bool settz) } else { + static char const tzbuf_format[] = "<%+.*"pI"d>%s%"pI"d:%02d:%02d"; + char const *trailing_tzbuf_format = tzbuf_format + sizeof "<%+.*"pI"d" - 1; + char tzbuf[sizeof tzbuf_format + 2 * INT_STRLEN_BOUND (EMACS_INT)]; + bool plain_integer = INTEGERP (zone); + if (EQ (zone, Qwall)) zone_string = 0; else if (STRINGP (zone)) - zone_string = SSDATA (zone); - else if (INTEGERP (zone)) + zone_string = SSDATA (ENCODE_SYSTEM (zone)); + else if (plain_integer || (CONSP (zone) && INTEGERP (XCAR (zone)) + && CONSP (XCDR (zone)))) { + Lisp_Object abbr; + if (!plain_integer) + { + abbr = XCAR (XCDR (zone)); + zone = XCAR (zone); + } + EMACS_INT abszone = eabs (XINT (zone)), hour = abszone / (60 * 60); - int min = (abszone / 60) % 60, sec = abszone % 60; - sprintf (tzbuf, tzbuf_format, &"-"[XINT (zone) < 0], hour, min, sec); - zone_string = tzbuf; + int hour_remainder = abszone % (60 * 60); + int min = hour_remainder / 60, sec = hour_remainder % 60; + + if (plain_integer) + { + int prec = 2; + EMACS_INT numzone = hour; + if (hour_remainder != 0) + { + prec += 2, numzone = 100 * numzone + min; + if (sec != 0) + prec += 2, numzone = 100 * numzone + sec; + } + sprintf (tzbuf, tzbuf_format, prec, numzone, + &"-"[XINT (zone) < 0], hour, min, sec); + zone_string = tzbuf; + } + else + { + AUTO_STRING (leading, "<"); + AUTO_STRING_WITH_LEN (trailing, tzbuf, + sprintf (tzbuf, trailing_tzbuf_format, + &"-"[XINT (zone) < 0], + hour, min, sec)); + zone_string = SSDATA (concat3 (leading, ENCODE_SYSTEM (abbr), + trailing)); + } } else xsignal2 (Qerror, build_string ("Invalid time zone specification"), @@ -1969,9 +2004,13 @@ DEFUN ("format-time-string", Fformat_time_string, Sformat_time_string, 1, 3, 0, doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted. TIME is specified as (HIGH LOW USEC PSEC), as returned by `current-time' or `file-attributes'. The obsolete form (HIGH . LOW) -is also still accepted. The optional ZONE is omitted or nil for Emacs -local time, t for Universal Time, `wall' for system wall clock time, -or a string as in the TZ environment variable. +is also still accepted. + +The optional ZONE is omitted or nil for Emacs local time, t for +Universal Time, `wall' for system wall clock time, or a string as in +the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') applied +without consideration for daylight saving time. The value is a copy of FORMAT-STRING, but with certain constructs replaced by text that describes the specified date and time in TIME: @@ -2085,9 +2124,12 @@ DEFUN ("decode-time", Fdecode_time, Sdecode_time, 0, 2, 0, The optional SPECIFIED-TIME should be a list of (HIGH LOW . IGNORED), as from `current-time' and `file-attributes', or nil to use the current time. The obsolete form (HIGH . LOW) is also still accepted. + The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in -the TZ environment variable. +the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') applied +without consideration for daylight saving time. The list has the following nine members: SEC is an integer between 0 and 60; SEC is 60 for a leap second, which only some operating systems @@ -2150,6 +2192,7 @@ check_tm_member (Lisp_Object obj, int offset) DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, doc: /* Convert SECOND, MINUTE, HOUR, DAY, MONTH, YEAR and ZONE to internal time. This is the reverse operation of `decode-time', which see. + The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in the TZ environment variable. It can also be a list (as from @@ -2184,8 +2227,6 @@ usage: (encode-time SECOND MINUTE HOUR DAY MONTH YEAR &optional ZONE) */) tm.tm_year = check_tm_member (args[5], TM_YEAR_BASE); tm.tm_isdst = -1; - if (CONSP (zone)) - zone = XCAR (zone); timezone_t tz = tzlookup (zone, false); value = emacs_mktime_z (tz, &tm); xtzfree (tz); @@ -2214,7 +2255,9 @@ but this is considered obsolete. The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in -the TZ environment variable. */) +the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') applied +without consideration for daylight saving time. */) (Lisp_Object specified_time, Lisp_Object zone) { time_t value = lisp_seconds_argument (specified_time); @@ -2290,8 +2333,12 @@ instead of using the current time. The argument should have the form \(HIGH LOW . IGNORED). Thus, you can use times obtained from `current-time' and from `file-attributes'. SPECIFIED-TIME can also have the form (HIGH . LOW), but this is considered obsolete. -Optional second arg ZONE is omitted or nil for the local time zone, or -a string as in the TZ environment variable. + +The optional ZONE is omitted or nil for Emacs local time, t for +Universal Time, `wall' for system wall clock time, or a string as in +the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') applied +without consideration for daylight saving time. Some operating systems cannot provide all this information to Emacs; in this case, `current-time-zone' returns a list containing nil for @@ -2315,15 +2362,18 @@ the data it can't find. */) zone_offset = make_number (offset); if (SCHARS (zone_name) == 0) { - /* No local time zone name is available; use "+-NNNN" instead. */ - long int m = offset / 60; - long int am = offset < 0 ? - m : m; - long int hour = am / 60; - int min = am % 60; - char buf[sizeof "+00" + INT_STRLEN_BOUND (long int)]; - zone_name = make_formatted_string (buf, "%c%02ld%02d", + /* No local time zone name is available; use numeric zone instead. */ + long int hour = offset / 3600; + int min_sec = offset % 3600; + int amin_sec = min_sec < 0 ? - min_sec : min_sec; + int min = amin_sec / 60; + int sec = amin_sec % 60; + int min_prec = min_sec ? 2 : 0; + int sec_prec = sec ? 2 : 0; + char buf[sizeof "+0000" + INT_STRLEN_BOUND (long int)]; + zone_name = make_formatted_string (buf, "%c%.2ld%.*d%.*d", (offset < 0 ? '-' : '+'), - hour, min); + hour, min_prec, min, sec_prec, sec); } } @@ -2332,11 +2382,11 @@ the data it can't find. */) DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, doc: /* Set the Emacs local time zone using TZ, a string specifying a time zone rule. - If TZ is nil or `wall', use system wall clock time; this differs from the usual Emacs convention where nil means current local time. If TZ -is t, use Universal Time. If TZ is an integer, treat it as in -`encode-time'. +is t, use Universal Time. If TZ is a list (as from +`current-time-zone') or an integer (as from `decode-time'), use the +specified time zone without consideration for daylight saving time. Instead of calling this function, you typically want something else. To temporarily use a different time zone rule for just one invocation commit 7c2c2196fd4be0b656bdf0e0b68f3d7c4a5eca08 Merge: 435da5d ca50981 Author: Paul Eggert Date: Tue Apr 12 08:50:47 2016 -0700 Merge from origin/emacs-25 ca50981 Improve time zone documentation c23c965 Prevent bootstrap autoload backup files 9344612 Disable multicolor fonts on OS X since they are not supported... c41ce1c Capitalize “Universal Time” in documentation 10597c9 Don't use 'find-program' commit ca509810014726cf6bee9f7e8f69bdeaf62dc146 Author: Paul Eggert Date: Tue Apr 12 08:47:15 2016 -0700 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. diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi index a842cb8..f0f686f 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 @env{TMP}, then @env{TEMP}, and finally @file{c:/temp}. @item TZ @vindex TZ, environment variable -This specifies the current time zone and possibly also daylight -saving time information. On MS-DOS, if @env{TZ} is not set in the +This specifies the default time zone and possibly also daylight +saving time information. @xref{Time Zone Rules,,, elisp, The GNU +Emacs Lisp Reference Manual}. On MS-DOS, if @env{TZ} is not set in the environment when Emacs starts, Emacs defines a default value as appropriate for the country code returned by DOS@. On MS-Windows, Emacs does not use @env{TZ} at all. diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi index 8839745..5f189b9 100644 --- a/doc/lispref/os.texi +++ b/doc/lispref/os.texi @@ -19,6 +19,7 @@ terminal and the screen. * System Environment:: Distinguish the name and kind of system. * User Identification:: Finding the name and user id of the user. * Time of Day:: Getting the current time. +* Time Zone Rules:: Rules for time zones and daylight saving time. * Time Conversion:: Converting a time from numeric form to calendrical data and vice versa. * Time Parsing:: Converting a time from numeric form to text @@ -1262,7 +1263,7 @@ information may some day be added at the end. The argument @var{time}, if given, specifies a time to format, instead of the current time. The optional argument @var{zone} -defaults to the current time zone rule. +defaults to the current time zone rule. @xref{Time Zone Rules}. @example @group @@ -1299,26 +1300,9 @@ For example, if @var{time} is a number, @code{(time-to-seconds or rounding errors occur. @end defun -@defun current-time-zone &optional time zone -@cindex time zone, current -This function returns a list describing the time zone that the user is -in. - -The value has the form @code{(@var{offset} @var{name})}. Here -@var{offset} is an integer giving the number of seconds ahead of Universal Time -(east of Greenwich). A negative value means west of Greenwich. The -second element, @var{name}, is a string giving the name of the time -zone. Both elements change when daylight saving time begins or ends; -if the user has specified a time zone that does not use a seasonal time -adjustment, then the value is constant through time. - -If the operating system doesn't supply all the information necessary to -compute the value, the unknown elements of the list are @code{nil}. - -The argument @var{time}, if given, specifies a time value to -analyze instead of the current time. The optional argument @var{zone} -defaults to the current time zone rule. -@end defun +@node Time Zone Rules +@section Time Zone Rules +@cindex time zone rules @vindex TZ, environment variable 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 @env{TZ} is not in the environment, Emacs uses system wall clock time, which is a platform-dependent default time zone. +The set of supported @env{TZ} strings is system-dependent. GNU and +many other systems support the tzdata database, e.g., +@samp{"America/New_York"} specifies the time zone and daylight saving +time history for locations near New York City. GNU and most other +systems support POSIX-style @env{TZ} strings, e.g., +@samp{"EST+5EDT,M4.1.0/2,M10.5.0/2"} specifies the rules used in New +York from 1987 through 2006. All systems support the string +@samp{"UTC0"} meaning Universal Time. + @cindex time zone rule Functions that convert to and from local time accept an optional @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 a string, the conversion uses the time zone rule equivalent to setting @env{TZ} to that string. +@defun current-time-zone &optional time zone +@cindex time zone, current +This function returns a list describing the time zone that the user is +in. + +The value has the form @code{(@var{offset} @var{abbr})}. Here +@var{offset} is an integer giving the number of seconds ahead of Universal Time +(east of Greenwich). A negative value means west of Greenwich. The +second element, @var{abbr}, is a string giving an abbreviation for the +time zone, e.g., @samp{"CST"} for China Standard Time or for +U.S. Central Standard Time. Both elements can change when daylight +saving time begins or ends; if the user has specified a time zone that +does not use a seasonal time adjustment, then the value is constant +through time. + +If the operating system doesn't supply all the information necessary to +compute the value, the unknown elements of the list are @code{nil}. + +The argument @var{time}, if given, specifies a time value to +analyze instead of the current time. The optional argument @var{zone} +defaults to the current time zone rule. +@end defun + @node Time Conversion @section Time Conversion @cindex calendrical information @@ -1361,8 +1377,8 @@ as traditional Gregorian years do; for example, the year number @defun decode-time &optional time zone This function converts a time value into calendrical information. If you don't specify @var{time}, it decodes the current time, and similarly -@var{zone} defaults to the current time zone rule. The return -value is a list of nine elements, as follows: +@var{zone} defaults to the current time zone rule. @xref{Time Zone Rules}. +The return value is a list of nine elements, as follows: @example (@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 yourself before you call @code{encode-time}. The optional argument @var{zone} defaults to the current time zone rule. +@xref{Time Zone Rules}. In addition to the usual time zone rule values, it can also be a list (as you would get from @code{current-time-zone}) or an integer (as from @code{decode-time}), applied without any further alteration for @@ -1452,8 +1469,8 @@ corresponding time value. This function converts @var{time} (or the current time, if @var{time} is omitted) to a string according to -@var{format-string}. The conversion uses the time zone rule @var{zone} -(or the current time zone rule, if omitted). The argument +@var{format-string}. The conversion uses the time zone rule @var{zone}, which +defaults to the current time zone rule. @xref{Time Zone Rules}. The argument @var{format-string} may contain @samp{%}-sequences which say to substitute parts of the time. Here is a table of what the @samp{%}-sequences mean: diff --git a/etc/NEWS b/etc/NEWS index fe7df96..bae42af 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1778,11 +1778,11 @@ quotation marks. *** Time conversion functions now accept an optional ZONE argument that specifies the time zone rules for conversion. ZONE is omitted or nil for Emacs local time, t for Universal Time, 'wall' for system wall -clock time, or a string as in 'set-time-zone-rule' for a time zone -rule. The affected functions are 'current-time-string', -'current-time-zone', 'decode-time', and 'format-time-string'. The -function 'encode-time', which already accepted a simple time zone rule -argument, has been extended to accept all the new forms. +clock time, or a string as in the TZ environment variable. The +affected functions are 'current-time-string', 'current-time-zone', +'decode-time', and 'format-time-string'. The function 'encode-time', +which already accepted a simple time zone rule argument, has been +extended to accept all the new forms. *** Incompatible change in the third argument of 'format-time-string'. Previously, any non-nil argument was interpreted as specifying Universal Time. diff --git a/etc/PROBLEMS b/etc/PROBLEMS index b0c21ee..be9400b 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -2220,11 +2220,11 @@ month names with consistent widths for some locales on some versions of Windows. This is caused by a deficiency in the underlying system library function. -** Problems with set-time-zone-rule function +** Non-US time zones. -The function set-time-zone-rule gives incorrect results for many -non-US timezones. This is due to over-simplistic handling of -daylight savings switchovers by the Windows libraries. +Many non-US time zones are implemented incorrectly. This is due to +over-simplistic handling of daylight savings switchovers by the +Windows libraries. ** Files larger than 4GB report wrong size in a 32-bit Windows build diff --git a/lisp/org/org.el b/lisp/org/org.el index d2b48a6..231daa9 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -22674,7 +22674,7 @@ time-range, if possible. The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in -`set-time-zone-rule' for a time zone rule." +the TZ environment variable." (format-time-string format (apply 'encode-time diff --git a/src/editfns.c b/src/editfns.c index 2ac0537..94b9495 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, doc: /* Use FORMAT-STRING to format the time TIME, or now if omitted. TIME is specified as (HIGH LOW USEC PSEC), as returned by `current-time' or `file-attributes'. The obsolete form (HIGH . LOW) -is also still accepted. -The optional ZONE is omitted or nil for Emacs local time, t for -Universal Time, `wall' for system wall clock time, or a string as in -`set-time-zone-rule' for a time zone rule. +is also still accepted. The optional ZONE is omitted or nil for Emacs +local time, t for Universal Time, `wall' for system wall clock time, +or a string as in the TZ environment variable. + The value is a copy of FORMAT-STRING, but with certain constructs replaced by text that describes the specified date and time in TIME: @@ -2086,7 +2086,7 @@ as from `current-time' and `file-attributes', or nil to use the current time. The obsolete form (HIGH . LOW) is also still accepted. The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in -`set-time-zone-rule' for a time zone rule. +the TZ environment variable. The list has the following nine members: SEC is an integer between 0 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, This is the reverse operation of `decode-time', which see. The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in -`set-time-zone-rule' for a time zone rule. It can also be a list (as -from `current-time-zone') or an integer (as from `decode-time') -applied without consideration for daylight saving time. +the TZ environment variable. It can also be a list (as from +`current-time-zone') or an integer (as from `decode-time') applied +without consideration for daylight saving time. You can pass more than 7 arguments; then the first six arguments are used as SECOND through YEAR, and the *last* argument is used as ZONE. @@ -2213,7 +2213,7 @@ but this is considered obsolete. The optional ZONE is omitted or nil for Emacs local time, t for Universal Time, `wall' for system wall clock time, or a string as in -`set-time-zone-rule' for a time zone rule. */) +the TZ environment variable. */) (Lisp_Object specified_time, Lisp_Object zone) { time_t value = lisp_seconds_argument (specified_time); @@ -2290,7 +2290,7 @@ instead of using the current time. The argument should have the form `current-time' and from `file-attributes'. SPECIFIED-TIME can also have the form (HIGH . LOW), but this is considered obsolete. Optional second arg ZONE is omitted or nil for the local time zone, or -a string as in `set-time-zone-rule'. +a string as in the TZ environment variable. Some operating systems cannot provide all this information to Emacs; in this case, `current-time-zone' returns a list containing nil for @@ -2331,8 +2331,11 @@ the data it can't find. */) DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, doc: /* Set the Emacs local time zone using TZ, a string specifying a time zone rule. -If TZ is nil or `wall', use system wall clock time. If TZ is t, use -Universal Time. If TZ is an integer, treat it as in `encode-time'. + +If TZ is nil or `wall', use system wall clock time; this differs from +the usual Emacs convention where nil means current local time. If TZ +is t, use Universal Time. If TZ is an integer, treat it as in +`encode-time'. Instead of calling this function, you typically want something else. To temporarily use a different time zone rule for just one invocation commit c23c965bb9d0a4bcc1b6158833ff99aa20fd53e9 Author: Phillip Lord Date: Fri Apr 8 16:22:44 2016 +0100 Prevent bootstrap autoload backup files * lisp/emacs-lisp/autoload (autoload-find-generated-file): Suppress backups in newly created file. (autoload-ensure-default-file): Function split into two. (autoload-ensure-file-writeable): New function from split. (Bug#23203) diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e688d6b..592d69d 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -234,9 +234,22 @@ If a buffer is visiting the desired autoload file, return it." (enable-local-eval nil)) ;; We used to use `raw-text' to read this file, but this causes ;; problems when the file contains non-ASCII characters. - (let ((delay-mode-hooks t)) - (find-file-noselect - (autoload-ensure-default-file (autoload-generated-file)))))) + (let* ((delay-mode-hooks t) + (file (autoload-generated-file)) + (file-missing (not (file-exists-p file)))) + (when file-missing + (autoload-ensure-default-file file)) + (with-current-buffer + (find-file-noselect + (autoload-ensure-file-writeable + file)) + ;; block backups when the file has just been created, since + ;; the backups will just be the auto-generated headers. + ;; bug#23203 + (when file-missing + (setq buffer-backed-up t) + (save-buffer)) + (current-buffer))))) (defun autoload-generated-file () (expand-file-name generated-autoload-file @@ -357,21 +370,22 @@ not be relied upon." ;;;###autoload (put 'autoload-ensure-writable 'risky-local-variable t) +(defun autoload-ensure-file-writeable (file) + ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, + ;; which was designed to handle CVSREAD=1 and equivalent. + (and autoload-ensure-writable + (let ((modes (file-modes file))) + (if (zerop (logand modes #o0200)) + ;; Ignore any errors here, and let subsequent attempts + ;; to write the file raise any real error. + (ignore-errors (set-file-modes file (logior modes #o0200)))))) + file) + (defun autoload-ensure-default-file (file) "Make sure that the autoload file FILE exists, creating it if needed. If the file already exists and `autoload-ensure-writable' is non-nil, make it writable." - (if (file-exists-p file) - ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, - ;; which was designed to handle CVSREAD=1 and equivalent. - (and autoload-ensure-writable - (let ((modes (file-modes file))) - (if (zerop (logand modes #o0200)) - ;; Ignore any errors here, and let subsequent attempts - ;; to write the file raise any real error. - (ignore-errors (set-file-modes file (logior modes #o0200)))))) - (write-region (autoload-rubric file) nil file)) - file) + (write-region (autoload-rubric file) nil file)) (defun autoload-insert-section-header (outbuf autoloads load-name file time) "Insert the section-header line, commit 9344612d3cd164317170b6189ec43175757e4231 Author: YAMAMOTO Mitsuharu Date: Tue Apr 12 08:26:51 2016 +0900 Disable multicolor fonts on OS X since they are not supported on free systems * src/macfont.m (macfont_list): Don't use color bitmap fonts. diff --git a/src/macfont.m b/src/macfont.m index c9082a5..0445628 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -2373,9 +2373,9 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no != (spacing >= FONT_SPACING_MONO))) continue; - /* Don't use a color bitmap font unless its family is - explicitly specified. */ - if ((sym_traits & kCTFontTraitColorGlyphs) && NILP (family)) + /* Don't use a color bitmap font until it is supported on + free platforms. */ + if (sym_traits & kCTFontTraitColorGlyphs) continue; if (j > 0 commit c41ce1cf3db45111cf4034d4a5fe6d98ada07b97 Author: Paul Eggert Date: Mon Apr 11 15:15:23 2016 -0700 Capitalize “Universal Time” in documentation It’s a proper noun. * lisp/vc/add-log.el (add-log-time-zone-rule): Also, fix typo by mentioning ‘format-time-string’ instead of ‘set-time-zone-rule’. diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index 15f5b74..c78d2bbf5 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el @@ -173,7 +173,7 @@ delta. At present, delta = 0.01 degrees, so the value of the variable ;;; End of user options. (defvar solar-sidereal-time-greenwich-midnight nil - "Sidereal time at Greenwich at midnight (universal time).") + "Sidereal time at Greenwich at midnight (Universal Time).") (defvar solar-northern-spring-or-summer-season nil "Non-nil if northern spring or summer and nil otherwise. @@ -413,8 +413,8 @@ Result is in days. For the years 1800-1987, the maximum error is (defun solar-ephemeris-time (time) "Ephemeris Time at moment TIME. TIME is a pair with the first component being the number of Julian centuries -elapsed at 0 Universal Time, and the second component being the universal -time. For instance, the pair corresponding to November 28, 1995 at 16 UT is +elapsed at 0 Universal Time, and the second component counting Universal Time +hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is \(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. @@ -430,7 +430,7 @@ Result is in Julian centuries of ephemeris time." "Right ascension (in hours) and declination (in degrees) of the sun at TIME. TIME is a pair with the first component being the number of Julian centuries elapsed at 0 Universal Time, and the second -component being the universal time. For instance, the pair +component counting Universal Time hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is (-0.040945 16), -0.040945 being the number of Julian centuries elapsed between Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. SUNRISE-FLAG is passed @@ -444,7 +444,7 @@ to `solar-ecliptic-coordinates'." "Azimuth and height of the sun at TIME, LATITUDE, and LONGITUDE. TIME is a pair with the first component being the number of Julian centuries elapsed at 0 Universal Time, and the second -component being the universal time. For instance, the pair +component counting Universal Time hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is (-0.040945 16), -0.040945 being the number of Julian centuries elapsed between Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. SUNRISE-FLAG @@ -476,8 +476,8 @@ Sunrise if DIRECTION =-1 or sunset if =1 at LATITUDE, LONGITUDE, with midday being TIME. TIME is a pair with the first component being the number of Julian centuries -elapsed at 0 Universal Time, and the second component being the universal -time. For instance, the pair corresponding to November 28, 1995 at 16 UT is +elapsed at 0 Universal Time, and the second component counting Universal Time +hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is \(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. @@ -522,8 +522,8 @@ Uses binary search." Parameters are the midday TIME and the LATITUDE, LONGITUDE of the location. TIME is a pair with the first component being the number of Julian centuries -elapsed at 0 Universal Time, and the second component being the universal -time. For instance, the pair corresponding to November 28, 1995 at 16 UT is +elapsed at 0 Universal Time, and the second component counting Universal Time +hours. For instance, the pair corresponding to November 28, 1995 at 16 UT is \(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 4ea8bae..66b1e38 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -1028,7 +1028,7 @@ on parts -- for instance, adding Vcard info to a database." (defcustom gnus-article-date-headers '(combined-lapsed) "A list of Date header formats to display. -Valid formats are `ut' (universal time), `local' (local time +Valid formats are `ut' (Universal Time), `local' (local time zone), `english' (readable English), `lapsed' (elapsed time), `combined-lapsed' (both the original date and the elapsed time), `original' (the original date header), `iso8601' (ISO8601 diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index 45e8633..fa02a5a 100644 --- a/lisp/vc/add-log.el +++ b/lisp/vc/add-log.el @@ -575,10 +575,9 @@ Compatibility function for \\[next-error] invocations." ;; called add-log-time-zone-rule since it's only used from add-log-* code. (defvaralias 'change-log-time-zone-rule 'add-log-time-zone-rule) (defvar add-log-time-zone-rule nil - "Time zone used for calculating change log time stamps. -It takes the same format as the TZ argument of `set-time-zone-rule'. -If nil, use local time. -If t, use universal time.") + "Time zone rule used for calculating change log time stamps. +If nil, use local time. If t, use Universal Time. +If a string, interpret as the ZONE argument of `format-time-string'.") (put 'add-log-time-zone-rule 'safe-local-variable (lambda (x) (or (booleanp x) (stringp x)))) commit 10597c977d55cbf9304b51c3b364ce58199384a0 Author: Eli Zaretskii Date: Mon Apr 11 19:41:48 2016 +0300 Don't use 'find-program' * lisp/progmodes/project.el (project-file-completion-table): Use 'grep-find-program', rather than the obsolete 'find-program'. diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 9c8a88c..82059c9 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -162,7 +162,7 @@ end it with `/'. DIR must be one of `project-roots' or DIRS is a list of absolute directories; it should be some subset of the project roots and external roots. -The default implementation uses `find-program'. PROJECT is used +The default implementation uses `grep-find-program'. PROJECT is used to find the list of ignores for each directory." ;; FIXME: Uniquely abbreviate the roots? (require 'xref) @@ -171,7 +171,7 @@ to find the list of ignores for each directory." (lambda (dir) (let ((command (format "%s %s %s -type f -print0" - find-program + grep-find-program dir (xref--find-ignores-arguments (project-ignores project dir)