2017-12-04 20:50:14 +00:00
|
|
|
;;; cal-dst.el --- calendar functions for daylight saving rules -*- lexical-binding:t -*-
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
;; Copyright (C) 1993-1996, 2001-2020 Free Software Foundation, Inc.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2019-05-26 07:58:28 +00:00
|
|
|
;; Author: Paul Eggert <eggert@cs.ucla.edu>
|
2008-03-13 06:29:28 +00:00
|
|
|
;; Edward M. Reingold <reingold@cs.uiuc.edu>
|
2019-06-01 19:11:55 +00:00
|
|
|
;; Maintainer: emacs-devel@gnu.org
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
;; Keywords: calendar
|
2007-03-17 17:49:59 +00:00
|
|
|
;; Human-Keywords: daylight saving time, calendar, diary, holidays
|
2010-08-29 16:17:13 +00:00
|
|
|
;; Package: calendar
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:07:58 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1994-04-07 20:30:18 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:07:58 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1994-04-07 20:30:18 +00:00
|
|
|
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
1994-04-07 20:30:18 +00:00
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 22:52:52 +00:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2008-04-01 02:39:52 +00:00
|
|
|
;; See calendar.el.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'calendar)
|
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
|
|
|
|
(defgroup calendar-dst nil
|
|
|
|
"Options related to Daylight Saving Time."
|
|
|
|
:prefix "calendar-"
|
|
|
|
:group 'calendar)
|
|
|
|
|
|
|
|
|
2006-11-10 08:54:38 +00:00
|
|
|
(defcustom calendar-dst-check-each-year-flag t
|
|
|
|
"Non-nil means to check each year for DST transitions as needed.
|
2006-11-10 15:04:03 +00:00
|
|
|
Otherwise assume the next two transitions found after the
|
2006-11-10 08:54:38 +00:00
|
|
|
current date apply to all years. This is faster, but not always
|
2007-03-17 17:49:59 +00:00
|
|
|
correct, since the dates of daylight saving transitions sometimes
|
2006-11-10 08:54:38 +00:00
|
|
|
change."
|
|
|
|
:type 'boolean
|
|
|
|
:version "22.1"
|
2008-04-11 03:43:55 +00:00
|
|
|
:group 'calendar-dst)
|
2006-11-10 08:54:38 +00:00
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
;;;###autoload
|
|
|
|
(put 'calendar-daylight-savings-starts 'risky-local-variable t)
|
|
|
|
(defcustom calendar-daylight-savings-starts '(calendar-dst-starts year)
|
|
|
|
"Sexp giving the date on which daylight saving time starts.
|
|
|
|
This is an expression in the variable `year' whose value gives the Gregorian
|
|
|
|
date in the form (month day year) on which daylight saving time starts. It is
|
|
|
|
used to determine the starting date of daylight saving time for the holiday
|
|
|
|
list and for correcting times of day in the solar and lunar calculations.
|
|
|
|
|
|
|
|
For example, if daylight saving time is mandated to start on October 1,
|
|
|
|
you would set `calendar-daylight-savings-starts' to
|
|
|
|
|
2019-11-11 18:30:13 +00:00
|
|
|
(10 1 year)
|
2008-03-07 05:13:00 +00:00
|
|
|
|
|
|
|
If it starts on the first Sunday in April, you would set it to
|
|
|
|
|
2019-11-11 18:30:13 +00:00
|
|
|
(calendar-nth-named-day 1 0 4 year)
|
2008-03-07 05:13:00 +00:00
|
|
|
|
|
|
|
If the locale never uses daylight saving time, set this to nil."
|
|
|
|
:type 'sexp
|
|
|
|
:group 'calendar-dst)
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(put 'calendar-daylight-savings-ends 'risky-local-variable t)
|
|
|
|
(defcustom calendar-daylight-savings-ends '(calendar-dst-ends year)
|
|
|
|
"Sexp giving the date on which daylight saving time ends.
|
|
|
|
This is an expression in the variable `year' whose value gives the Gregorian
|
|
|
|
date in the form (month day year) on which daylight saving time ends. It is
|
|
|
|
used to determine the starting date of daylight saving time for the holiday
|
|
|
|
list and for correcting times of day in the solar and lunar calculations.
|
|
|
|
|
|
|
|
For example, if daylight saving time ends on the last Sunday in October:
|
|
|
|
|
2015-09-02 01:21:42 +00:00
|
|
|
(calendar-nth-named-day -1 0 10 year)
|
2008-03-07 05:13:00 +00:00
|
|
|
|
|
|
|
If the locale never uses daylight saving time, set this to nil."
|
|
|
|
:type 'sexp
|
|
|
|
:group 'calendar-dst)
|
|
|
|
|
|
|
|
;;; More defcustoms below.
|
|
|
|
|
|
|
|
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(defvar calendar-current-time-zone-cache nil
|
2006-12-24 02:58:41 +00:00
|
|
|
"Cache for result of `calendar-current-time-zone'.")
|
2008-04-11 03:43:55 +00:00
|
|
|
;; It gets eval'd, eg by calendar-dst-starts.
|
|
|
|
;;;###autoload
|
|
|
|
(put 'calendar-current-time-zone-cache 'risky-local-variable t)
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
(defconst calendar-system-time-basis
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(calendar-absolute-from-gregorian '(1 1 1970))
|
|
|
|
"Absolute date of starting date of system clock.")
|
|
|
|
|
|
|
|
(defun calendar-absolute-from-time (x utc-diff)
|
|
|
|
"Absolute local date of time X; local time is UTC-DIFF seconds from UTC.
|
|
|
|
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
X is the number of seconds since 1970-01-01 00:00:00 UTC,
|
|
|
|
ignoring leap seconds.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
Returns the pair (ABS-DATE . SECONDS) where SECONDS after local midnight on
|
|
|
|
absolute date ABS-DATE is the equivalent moment to X."
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
(let ((secsperday 86400)
|
|
|
|
(local (+ x utc-diff)))
|
|
|
|
(cons (+ calendar-system-time-basis (floor local secsperday))
|
|
|
|
(mod local secsperday))))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
(defun calendar-time-from-absolute (abs-date s)
|
|
|
|
"Time of absolute date ABS-DATE, S seconds after midnight.
|
|
|
|
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
Return the number of seconds since 1970-01-01 00:00:00 UTC,
|
|
|
|
ignoring leap seconds, that is the equivalent moment to S seconds
|
|
|
|
after midnight UTC on absolute date ABS-DATE."
|
|
|
|
(let ((secsperday 86400))
|
|
|
|
(+ s (* secsperday (- abs-date calendar-system-time-basis)))))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
(defun calendar-next-time-zone-transition (time)
|
|
|
|
"Return the time of the next time zone transition after TIME.
|
2008-03-08 20:41:30 +00:00
|
|
|
Both TIME and the result are acceptable arguments to `current-time-zone'.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
Return nil if no such transition can be found."
|
New function time-convert
This replaces the awkward reuse of encode-time to both convert
calendrical timestamps to Lisp timestamps, and to convert Lisp
timestamps to other forms. Now, encode-time does just the
former and the new function does just the latter.
The new function builds on a suggestion by Lars Ingebrigtsen in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html
and refined by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html
* doc/lispref/os.texi (Time of Day, Time Conversion):
* doc/misc/emacs-mime.texi (time-date):
* etc/NEWS: Update documentation.
* lisp/calendar/cal-dst.el (calendar-next-time-zone-transition):
* lisp/calendar/time-date.el (seconds-to-time, days-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-add-item):
* lisp/emacs-lisp/cl-extra.el (cl--random-time):
* lisp/emacs-lisp/timer.el (timer--time-setter)
(timer-next-integral-multiple-of-time):
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-diary.el (gnus-user-format-function-d):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
* lisp/gnus/nnrss.el (nnrss-normalize-date):
* lisp/gnus/nnspool.el (nnspool-request-newgroups):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/net/pop3.el (pop3-uidl-dele):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-clock-in)
(org-clock-out, org-clock-sum):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cc-cmds.el (c-progress-init)
(c-progress-update):
* lisp/progmodes/cperl-mode.el (cperl-time-fontification):
* lisp/progmodes/flymake.el (flymake--schedule-timer-maybe):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
* lisp/tar-mode.el (tar-octal-time):
* lisp/time.el (emacs-uptime):
* lisp/url/url-auth.el (url-digest-auth-make-cnonce):
* lisp/url/url-util.el (url-lazy-message):
* lisp/vc/vc-cvs.el (vc-cvs-parse-entry):
* lisp/vc/vc-hg.el (vc-hg-state-fast):
* lisp/xt-mouse.el (xterm-mouse-event):
* test/lisp/emacs-lisp/timer-tests.el:
(timer-next-integral-multiple-of-time-2):
Use time-convert, not encode-time.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
Don’t use now-removed FORM argument for encode-time.
It wasn’t crucial anyway.
* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert.
* lisp/emacs-lisp/elint.el (elint-unknown-builtin-args):
Update encode-time signature to match current arg set.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Use timer-convert with t rather than doing it by hand.
* src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp):
Remove; no longer needed.
(decode_lisp_time): Rturn the form instead of having a *PFORM arg.
All uses changed.
(time_arith): Just return TICKS if HZ is 1.
(Fencode_time): Remove argument FORM. All callers changed.
Do not attempt to encode time values; just encode
decoded (calendrical) times.
Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1.
(Ftime_convert): New function, which does the time value
conversion that bleeding-edge encode-time formerly did.
Return TIME if it is easy to see that it is already
of the correct form.
(Fcurrent_time): Mention in doc that the form is planned to change.
* test/src/timefns-tests.el (decode-then-encode-time):
Don’t use (encode-time nil).
2019-08-06 00:38:52 +00:00
|
|
|
(let* ((time (time-convert time 'integer))
|
2008-03-13 06:29:28 +00:00
|
|
|
(time-zone (current-time-zone time))
|
|
|
|
(time-utc-diff (car time-zone))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
hi
|
2008-03-13 06:29:28 +00:00
|
|
|
hi-zone
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(hi-utc-diff time-utc-diff)
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
(quarter-seconds 7889238) ; Average seconds per 1/4 Gregorian year.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(quarters '(2 1 3)))
|
|
|
|
;; Heuristic: probe the time zone offset in the next three calendar
|
|
|
|
;; quarters, looking for a time zone offset different from TIME.
|
|
|
|
(while (and quarters (eq time-utc-diff hi-utc-diff))
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
(setq hi (+ time (* (car quarters) quarter-seconds))
|
2008-03-14 03:38:38 +00:00
|
|
|
hi-zone (current-time-zone hi)
|
|
|
|
hi-utc-diff (car hi-zone)
|
|
|
|
quarters (cdr quarters)))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(and
|
|
|
|
time-utc-diff
|
|
|
|
hi-utc-diff
|
|
|
|
(not (eq time-utc-diff hi-utc-diff))
|
|
|
|
;; Now HI is after the next time zone transition.
|
|
|
|
;; Set LO to TIME, and then binary search to increase LO and decrease HI
|
|
|
|
;; until LO is just before and HI is just after the time zone transition.
|
New (TICKS . HZ) timestamp format
This follows on a suggestion by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2018-08/msg00991.html
(Bug#32902).
* doc/lispref/buffers.texi (Modification Time):
* doc/lispref/os.texi (Processor Run Time, Time Calculations)
* doc/lispref/processes.texi (System Processes):
* doc/lispref/text.texi (Undo):
Let the "Time of Day" section cover timestamp format details.
* doc/lispref/os.texi (Time of Day):
Say that timestamp internal format should not be assumed.
Document new (ticks . hz) format. Omit mention of seconds-to-time
since it is now just an alias for encode-time.
(Time Conversion): Document encode-time extension.
* etc/NEWS: Mention changes.
* lisp/calendar/cal-dst.el (calendar-system-time-basis): Now const.
* lisp/calendar/cal-dst.el (calendar-absolute-from-time)
(calendar-time-from-absolute)
(calendar-next-time-zone-transition):
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums, (TICKS . HZ), and new encode-time.
* lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time):
Simplify by using bignums and new encode-time.
* lisp/calendar/parse-time.el (parse-iso8601-time-string):
Handle DST more accurately, by using new encode-time.
* lisp/calendar/time-date.el (seconds-to-time):
* lisp/calendar/timeclock.el (timeclock-seconds-to-time):
Now just an alias for encode-time.
* lisp/calendar/time-date.el (days-to-time):
* lisp/emacs-lisp/timer.el (timer--time-setter):
* lisp/net/ntlm.el (ntlm-compute-timestamp):
* lisp/obsolete/vc-arch.el (vc-arch-add-tagline):
* lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36):
* lisp/tar-mode (tar-octal-time):
Don't assume timestamps default to list form.
* lisp/tar-mode.el (tar-parse-octal-long-integer):
Now an obsolete alias for tar-parse-octal-integer.
* src/keyboard.c (decode_timer): Adjust to changes to
time decoding functions elsewhere.
* src/timefns.c: Include bignum.h, limits.h.
(FASTER_TIMEFNS): New macro.
(WARN_OBSOLETE_TIMESTAMPS, CURRENT_TIME_LIST)
(timespec_hz, trillion, ztrillion):
New constants.
(make_timeval): Use TIME_T_MAX instead of its definiens.
(check_time_validity, time_add, time_subtract):
Remove. All uses removed.
(disassemble_lisp_time): Remove; old code now folded into
decode_lisp_time. All callers changed.
(invalid_hz, s_ns_to_double, ticks_hz_list4, mpz_set_time)
(timespec_mpz, timespec_ticks, time_hz_ticks)
(lisp_time_hz_ticks, lisp_time_seconds)
(time_form_stamp, lisp_time_form_stamp, decode_ticks_hz)
(decode_lisp_time, mpz_time, list4_to_timespec):
New functions.
(decode_float_time, decode_time_components, lisp_to_timespec):
Adjust to new struct lisp_time, which does not lose
information like the old one did.
(enum timeform): New enum.
(decode_time_components): New arg FORM. All callers changed.
RESULT and DRESULT are now mutually exclusive; no callers need
to change because of this.
(decode_time_components, lisp_time_struct)
(lisp_seconds_argument, time_arith, make_lisp_time, Ffloat_time)
(Fencode_time):
Add support for (TICKS . HZ) form.
(DECODE_SECS_ONLY): New constant.
(lisp_time_struct): 2nd arg is now enum timeform, not int.
All callers changed.
(check_tm_member): Support bignums.m
(Fencode_time): Add new two-arg functionality.
* src/systime.h (struct lisp_time): Now ticks+hz rather than
hi+lo+us+ps, since ticks+hz does not lose info.
* test/src/systime-tests.el (time-equal-p-nil-nil):
New test.
2018-10-03 16:10:01 +00:00
|
|
|
(let* ((lo time)
|
2008-03-13 06:29:28 +00:00
|
|
|
probe)
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(while
|
2008-03-13 06:29:28 +00:00
|
|
|
;; Set PROBE to halfway between LO and HI, rounding down.
|
|
|
|
;; If PROBE equals LO, we are done.
|
2018-11-14 19:42:59 +00:00
|
|
|
(not (= lo (setq probe (floor (+ lo hi) 2))))
|
2008-03-13 06:29:28 +00:00
|
|
|
;; Set either LO or HI to PROBE, depending on probe results.
|
|
|
|
(if (eq (car (current-time-zone probe)) hi-utc-diff)
|
|
|
|
(setq hi probe)
|
|
|
|
(setq lo probe)))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
hi))))
|
|
|
|
|
2008-04-04 07:37:36 +00:00
|
|
|
(autoload 'calendar-persian-to-absolute "cal-persia")
|
2008-03-26 03:10:23 +00:00
|
|
|
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(defun calendar-time-zone-daylight-rules (abs-date utc-diff)
|
|
|
|
"Return daylight transition rule for ABS-DATE, UTC-DIFF sec offset from UTC.
|
2007-03-17 17:49:59 +00:00
|
|
|
ABS-DATE must specify a day that contains a daylight saving transition.
|
|
|
|
The result has the proper form for `calendar-daylight-savings-starts'."
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(let* ((date (calendar-gregorian-from-absolute abs-date))
|
2008-03-13 06:29:28 +00:00
|
|
|
(weekday (% abs-date 7))
|
2008-04-07 01:59:37 +00:00
|
|
|
(m (calendar-extract-month date))
|
|
|
|
(d (calendar-extract-day date))
|
|
|
|
(y (calendar-extract-year date))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(last (calendar-last-day-of-month m y))
|
2008-04-02 03:18:55 +00:00
|
|
|
j rlist
|
|
|
|
(candidate-rules ; these return Gregorian dates
|
2008-03-13 06:29:28 +00:00
|
|
|
(append
|
|
|
|
;; Day D of month M.
|
2008-04-02 03:18:55 +00:00
|
|
|
`((list ,m ,d year))
|
2008-03-13 06:29:28 +00:00
|
|
|
;; The first WEEKDAY of month M.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(if (< d 8)
|
2008-04-02 03:18:55 +00:00
|
|
|
`((calendar-nth-named-day 1 ,weekday ,m year)))
|
2008-03-13 06:29:28 +00:00
|
|
|
;; The last WEEKDAY of month M.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(if (> d (- last 7))
|
2008-04-02 03:18:55 +00:00
|
|
|
`((calendar-nth-named-day -1 ,weekday ,m year)))
|
|
|
|
(progn
|
|
|
|
;; The first WEEKDAY after day J of month M, for D-6 < J <= D.
|
|
|
|
(setq j (1- (max 2 (- d 6))))
|
|
|
|
(while (<= (setq j (1+ j)) (min d (- last 8)))
|
|
|
|
(push `(calendar-nth-named-day 1 ,weekday ,m year ,j) rlist))
|
|
|
|
rlist)
|
2008-03-13 06:29:28 +00:00
|
|
|
;; 01-01 and 07-01 for this year's Persian calendar.
|
2008-04-02 03:18:55 +00:00
|
|
|
;; FIXME what does the Persian calendar have to do with this?
|
2009-06-23 07:30:25 +00:00
|
|
|
(and (= m 3) (memq d '(20 21))
|
|
|
|
'((calendar-gregorian-from-absolute
|
|
|
|
(calendar-persian-to-absolute `(1 1 ,(- year 621))))))
|
|
|
|
(and (= m 9) (memq d '(22 23))
|
|
|
|
'((calendar-gregorian-from-absolute
|
|
|
|
(calendar-persian-to-absolute `(7 1 ,(- year 621))))))))
|
2008-03-15 02:58:24 +00:00
|
|
|
(prevday-sec (- -1 utc-diff)) ; last sec of previous local day
|
2008-04-02 03:18:55 +00:00
|
|
|
new-rules)
|
2017-12-04 20:50:14 +00:00
|
|
|
(calendar-dlet* ((year (1+ y)))
|
|
|
|
;; Scan through the next few years until only one rule remains.
|
|
|
|
(while (cdr candidate-rules)
|
|
|
|
(dolist (rule candidate-rules)
|
|
|
|
;; The rule we return should give a Gregorian date, but here
|
|
|
|
;; we require an absolute date. The following is for efficiency.
|
|
|
|
(setq date (cond ((eq (car rule) #'calendar-nth-named-day)
|
|
|
|
(eval (cons #'calendar-nth-named-absday
|
|
|
|
(cdr rule))))
|
|
|
|
((eq (car rule) #'calendar-gregorian-from-absolute)
|
|
|
|
(eval (cadr rule)))
|
|
|
|
(t (calendar-absolute-from-gregorian (eval rule)))))
|
|
|
|
(or (equal (current-time-zone
|
|
|
|
(calendar-time-from-absolute date prevday-sec))
|
|
|
|
(current-time-zone
|
|
|
|
(calendar-time-from-absolute (1+ date) prevday-sec)))
|
|
|
|
(setq new-rules (cons rule new-rules))))
|
|
|
|
;; If no rules remain, just use the first candidate rule;
|
|
|
|
;; it's wrong in general, but it's right for at least one year.
|
|
|
|
(setq candidate-rules (if new-rules (nreverse new-rules)
|
|
|
|
(list (car candidate-rules)))
|
|
|
|
new-rules nil
|
|
|
|
year (1+ year))))
|
(calendar-time-zone-daylight-rules): Scan through the
next few years until at most one rule remains; if none remain, then
just use the first candidate rule; it's wrong in general, but it's
right for at least one year. This is a better heuristic in case the
underlying time zone implementation has bugs (which is all too
common). If possible, don't convert back and forth between gregorian
and absolute; this speeds things up noticeably. This uses the new
calendar-nth-named-absday function.
(calendar-current-time-zone): Some locales start DST at a different
time of day than they end; allow for this by yielding both times. The
performance speedups in calendar.el are great enough that we now no
longer need the "Checking time zone data..." message. If
current-time-zone yields nil, don't bother with
calendar-next-time-zone-transition. Use clearer names for local vars.
(calendar-time-zone, calendar-daylight-time-offset,
calendar-{standard,daylight}-time-zone-name,
calendar-daylight-savings-{starts,ends}): Default to US Eastern rules
for information that is not available.
(calendar-daylight-savings-{starts,ends}-time): New vars, replacing
calendar-daylight-savings-switchover-time, to support locales that
start DST at a different time of day than they end.
(calendar-absolute-from-time):
Fix typo by interchanging floor and mod.
1993-08-28 04:14:25 +00:00
|
|
|
(car candidate-rules)))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2006-11-10 08:54:38 +00:00
|
|
|
;; TODO it might be better to extract this information directly from
|
|
|
|
;; the system timezone database. But cross-platform...?
|
|
|
|
;; See thread
|
2017-11-26 06:45:41 +00:00
|
|
|
;; https://lists.gnu.org/r/emacs-pretest-bug/2006-11/msg00060.html
|
2006-11-10 08:54:38 +00:00
|
|
|
(defun calendar-dst-find-data (&optional time)
|
2007-03-17 17:49:59 +00:00
|
|
|
"Find data on the first daylight saving time transitions after TIME.
|
Avoid some double-rounding of Lisp timestamps
Also, simplify some time-related Lisp timestamp code
while we’re in the neighborhood.
* lisp/battery.el (battery-linux-proc-acpi)
(battery-linux-sysfs, battery-upower, battery-bsd-apm):
* lisp/calendar/timeclock.el (timeclock-seconds-to-string)
(timeclock-log, timeclock-last-period)
(timeclock-entry-length, timeclock-entry-list-span)
(timeclock-find-discrep, timeclock-generate-report):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/ecomplete.el (ecomplete-decay-1):
* lisp/emacs-lisp/ert.el (ert--results-update-stats-display)
(ert--results-update-stats-display-maybe):
* lisp/emacs-lisp/timer-list.el (list-timers):
* lisp/emacs-lisp/timer.el (timer-until)
(timer-event-handler):
* lisp/erc/erc-backend.el (erc-server-send-ping)
(erc-server-send-queue, erc-handle-parsed-server-response)
(erc-handle-unknown-server-response):
* lisp/erc/erc-track.el (erc-buffer-visible):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p)
(erc-cmd-PING, erc-send-current-line):
* lisp/eshell/em-pred.el (eshell-pred-file-time):
* lisp/eshell/em-unix.el (eshell-show-elapsed-time):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event:org-timestamp):
* lisp/gnus/gnus-int.el (gnus-backend-trace):
* lisp/gnus/gnus-sum.el (gnus-user-date):
* lisp/gnus/mail-source.el (mail-source-delete-crash-box):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/ibuf-ext.el (ibuffer-mark-old-buffers):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/mouse.el (mouse--down-1-maybe-follows-link)
(mouse--click-1-maybe-follows-link):
* lisp/mpc.el (mpc--faster-toggle):
* lisp/net/rcirc.el (rcirc-handler-ctcp-KEEPALIVE)
(rcirc-sentinel):
* lisp/net/tramp-cache.el (tramp-get-file-property):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-newer-than-file-p)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/org/org-clock.el (org-clock-resolve):
(org-resolve-clocks, org-clock-in, org-clock-out, org-clock-sum):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds):
* lisp/org/org.el (org-evaluate-time-range):
* lisp/org/ox-publish.el (org-publish-cache-ctime-of-src):
* lisp/pixel-scroll.el (pixel-scroll-in-rush-p):
* lisp/play/hanoi.el (hanoi-move-ring):
* lisp/proced.el (proced-format-time):
* lisp/progmodes/cpp.el (cpp-progress-message):
* lisp/progmodes/flymake.el (flymake--handle-report):
* lisp/progmodes/js.el (js--wait-for-matching-output):
* lisp/subr.el (progress-reporter-do-update):
* lisp/term/xterm.el (xterm--read-event-for-query):
* lisp/time.el (display-time-update, emacs-uptime):
* lisp/tooltip.el (tooltip-delay):
* lisp/url/url-cookie.el (url-cookie-parse-file-netscape):
* lisp/url/url-queue.el (url-queue-prune-old-entries):
* lisp/url/url.el (url-retrieve-synchronously):
* lisp/xt-mouse.el (xterm-mouse-event):
Avoid double-rounding of time-related values. Simplify.
* lisp/calendar/icalendar.el (icalendar--decode-isodatetime):
When hoping for the best (unlikely), use a better decoded time.
(icalendar--convert-sexp-to-ical): Avoid unnecessary encode-time.
* lisp/calendar/timeclock.el (timeclock-when-to-leave):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-clock.el (org-clock-get-clocked-time)
(org-clock-resolve, org-resolve-clocks, org-resolve-clocks-if-idle):
* lisp/org/org-habit.el (org-habit-insert-consistency-graphs):
* lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
(vhdl-fix-case-region-1):
Use time-since instead of open-coding most of it.
* lisp/erc/erc-dcc.el (erc-dcc-get-sentinel):
* lisp/erc/erc.el (erc-string-to-emacs-time, erc-time-gt):
Now obsolete. All uses changed.
(erc-time-diff): Accept all Lisp time values.
All uses changed.
* lisp/gnus/gnus-demon.el (gnus-demon-idle-since):
* lisp/gnus/gnus-score.el (gnus-score-headers):
* lisp/gnus/nneething.el (nneething-make-head):
* lisp/gnus/nnheader.el (nnheader-message-maybe):
* lisp/gnus/nnimap.el (nnimap-keepalive):
* lisp/image.el (image-animate-timeout):
* lisp/mail/feedmail.el (feedmail-rfc822-date):
* lisp/net/imap.el (imap-wait-for-tag):
* lisp/net/newst-backend.el (newsticker--image-get):
* lisp/net/rcirc.el (rcirc-handler-317, rcirc-handler-333):
* lisp/obsolete/xesam.el (xesam-refresh-entry):
* lisp/org/org-agenda.el (org-agenda-show-clocking-issues)
(org-agenda-check-clock-gap, org-agenda-to-appt):
* lisp/org/org-capture.el (org-capture-set-target-location):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clocktable-steps):
* lisp/org/org-colview.el (org-columns-edit-value)
(org-columns, org-agenda-columns):
* lisp/org/org-duration.el (org-duration-from-minutes):
* lisp/org/org-element.el (org-element-cache-sync-duration)
(org-element-cache-sync-break)
(org-element--cache-interrupt-p, org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-table.el (org-table-sum):
* lisp/org/org-timer.el (org-timer-show-remaining-time)
(org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-today)
(org-auto-repeat-maybe, org-2ft, org-time-stamp)
(org-read-date-analyze, org-time-stamp-to-now)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/ses.el (ses--time-check):
* lisp/type-break.el (type-break-time-warning)
(type-break-statistics, type-break-demo-boring):
* lisp/url/url-cache.el (url-cache-expired)
(url-cache-prune-cache):
* lisp/vc/vc-git.el (vc-git-stash-snapshot):
* lisp/erc/erc-match.el (erc-log-matches-come-back):
Simplify.
2019-02-23 02:32:31 +00:00
|
|
|
TIME defaults to the current time. Return value is as described
|
2006-11-10 08:54:38 +00:00
|
|
|
for `calendar-current-time-zone'."
|
|
|
|
(let* ((t0 (or time (current-time)))
|
|
|
|
(t0-zone (current-time-zone t0))
|
|
|
|
(t0-utc-diff (car t0-zone))
|
2008-03-14 03:38:38 +00:00
|
|
|
(t0-name (cadr t0-zone)))
|
2006-11-10 08:54:38 +00:00
|
|
|
(if (not t0-utc-diff)
|
|
|
|
;; Little or no time zone information is available.
|
|
|
|
(list nil nil t0-name t0-name nil nil nil nil)
|
|
|
|
(let* ((t1 (calendar-next-time-zone-transition t0))
|
|
|
|
(t2 (and t1 (calendar-next-time-zone-transition t1))))
|
|
|
|
(if (not t2)
|
2007-03-17 17:49:59 +00:00
|
|
|
;; This locale does not have daylight saving time.
|
2006-11-10 08:54:38 +00:00
|
|
|
(list (/ t0-utc-diff 60) 0 t0-name t0-name nil nil 0 0)
|
2007-03-17 17:49:59 +00:00
|
|
|
;; Use heuristics to find daylight saving parameters.
|
2006-11-10 08:54:38 +00:00
|
|
|
(let* ((t1-zone (current-time-zone t1))
|
|
|
|
(t1-utc-diff (car t1-zone))
|
2008-03-14 03:38:38 +00:00
|
|
|
(t1-name (cadr t1-zone))
|
2006-11-10 08:54:38 +00:00
|
|
|
(t1-date-sec (calendar-absolute-from-time t1 t0-utc-diff))
|
|
|
|
(t2-date-sec (calendar-absolute-from-time t2 t1-utc-diff))
|
|
|
|
;; TODO When calendar-dst-check-each-year-flag is non-nil,
|
|
|
|
;; the rules can be simpler than they currently are.
|
|
|
|
(t1-rules (calendar-time-zone-daylight-rules
|
|
|
|
(car t1-date-sec) t0-utc-diff))
|
|
|
|
(t2-rules (calendar-time-zone-daylight-rules
|
|
|
|
(car t2-date-sec) t1-utc-diff))
|
|
|
|
(t1-time (/ (cdr t1-date-sec) 60))
|
|
|
|
(t2-time (/ (cdr t2-date-sec) 60)))
|
2019-07-30 11:06:06 +00:00
|
|
|
(if (decoded-time-dst (decode-time t1))
|
2017-12-08 20:11:25 +00:00
|
|
|
(list (/ t0-utc-diff 60) (/ (- t1-utc-diff t0-utc-diff) 60)
|
|
|
|
t0-name t1-name t1-rules t2-rules t1-time t2-time)
|
|
|
|
(list (/ t1-utc-diff 60) (/ (- t0-utc-diff t1-utc-diff) 60)
|
|
|
|
t1-name t0-name t2-rules t1-rules t2-time t1-time))))))))
|
2006-11-10 08:54:38 +00:00
|
|
|
|
|
|
|
(defvar calendar-dst-transition-cache nil
|
2007-03-17 17:49:59 +00:00
|
|
|
"Internal cal-dst variable storing date of daylight saving time transitions.
|
2006-11-10 08:54:38 +00:00
|
|
|
Value is a list with elements of the form (YEAR START END), where
|
|
|
|
START and END are expressions that when evaluated return the
|
2008-03-08 20:41:30 +00:00
|
|
|
start and end dates (respectively) for DST in YEAR. Used by the
|
2006-11-10 08:54:38 +00:00
|
|
|
function `calendar-dst-find-startend'.")
|
|
|
|
|
|
|
|
(defun calendar-dst-find-startend (year)
|
2007-03-17 17:49:59 +00:00
|
|
|
"Find the dates in YEAR on which daylight saving time starts and ends.
|
2006-11-10 08:54:38 +00:00
|
|
|
Returns a list (YEAR START END), where START and END are
|
|
|
|
expressions that when evaluated return the start and end dates,
|
lisp/*.el: Fix typos and other trivial doc fixes
* lisp/allout-widgets.el (allout-widgets-auto-activation)
(allout-current-decorated-p):
* lisp/auth-source.el (auth-source-protocols):
* lisp/autorevert.el (auto-revert-set-timer):
* lisp/battery.el (battery-mode-line-limit):
* lisp/calc/calcalg3.el (math-map-binop):
* lisp/calendar/cal-dst.el (calendar-dst-find-startend):
* lisp/calendar/cal-mayan.el (calendar-mayan-long-count-to-absolute):
* lisp/calendar/calendar.el (calendar-date-echo-text)
(calendar-generate-month, calendar-string-spread)
(calendar-cursor-to-date, calendar-read, calendar-read-date)
(calendar-mark-visible-date, calendar-dayname-on-or-before):
* lisp/calendar/diary-lib.el (diary-ordinal-suffix):
* lisp/cedet/ede/autoconf-edit.el (autoconf-new-program)
(autoconf-find-last-macro, autoconf-parameter-strip):
* lisp/cedet/ede/config.el (ede-target-with-config-build):
* lisp/cedet/ede/linux.el (ede-linux--detect-architecture)
(ede-linux--get-architecture):
* lisp/cedet/semantic/complete.el (semantic-collector-calculate-cache)
(semantic-displayer-abstract, semantic-displayer-point-position):
* lisp/cedet/semantic/format.el (semantic-format-face-alist)
(semantic-format-tag-short-doc):
* lisp/cedet/semantic/fw.el (semantic-find-file-noselect):
* lisp/cedet/semantic/idle.el (semantic-idle-scheduler-work-idle-time)
(semantic-idle-breadcrumbs-display-function)
(semantic-idle-breadcrumbs-format-tag-list-function):
* lisp/cedet/semantic/lex.el (semantic-lex-map-types)
(define-lex, define-lex-block-type-analyzer):
* lisp/cedet/semantic/senator.el (senator-search-default-tag-filter):
* lisp/cedet/semantic/symref.el (semantic-symref-result)
(semantic-symref-hit-to-tag-via-db):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-baseclass):
* lisp/cedet/semantic/tag.el (semantic-tag-new-variable)
(semantic-tag-new-include, semantic-tag-new-package)
(semantic-tag-set-faux, semantic-create-tag-proxy)
(semantic-tag-function-parent)
(semantic-tag-components-with-overlays):
* lisp/cedet/srecode/cpp.el (srecode-cpp-namespaces)
(srecode-semantic-handle-:c, srecode-semantic-apply-tag-to-dict):
* lisp/cedet/srecode/dictionary.el (srecode-create-dictionary)
(srecode-dictionary-add-entries, srecode-dictionary-lookup-name)
(srecode-create-dictionaries-from-tags):
* lisp/cmuscheme.el (scheme-compile-region):
* lisp/color.el (color-lab-to-lch):
* lisp/doc-view.el (doc-view-image-width)
(doc-view-set-up-single-converter):
* lisp/dynamic-setting.el (font-setting-change-default-font)
(dynamic-setting-handle-config-changed-event):
* lisp/elec-pair.el (electric-pair-text-pairs)
(electric-pair-skip-whitespace-function)
(electric-pair-string-bound-function):
* lisp/emacs-lisp/avl-tree.el (avl-tree--del-balance)
(avl-tree-member, avl-tree-mapcar, avl-tree-iter):
* lisp/emacs-lisp/bytecomp.el (byte-compile-generate-call-tree):
* lisp/emacs-lisp/checkdoc.el (checkdoc-autofix-flag)
(checkdoc-spellcheck-documentation-flag, checkdoc-ispell)
(checkdoc-ispell-current-buffer, checkdoc-ispell-interactive)
(checkdoc-ispell-message-interactive)
(checkdoc-ispell-message-text, checkdoc-ispell-start)
(checkdoc-ispell-continue, checkdoc-ispell-comments)
(checkdoc-ispell-defun):
* lisp/emacs-lisp/cl-generic.el (cl--generic-search-method):
* lisp/emacs-lisp/eieio-custom.el (eieio-read-customization-group):
* lisp/emacs-lisp/lisp.el (forward-sexp, up-list):
* lisp/emacs-lisp/package-x.el (package--archive-contents-from-file):
* lisp/emacs-lisp/package.el (package-desc)
(package--make-autoloads-and-stuff, package-hidden-regexps):
* lisp/emacs-lisp/tcover-ses.el (ses-exercise-startup):
* lisp/emacs-lisp/testcover.el (testcover-nohits)
(testcover-1value):
* lisp/epg.el (epg-receive-keys, epg-start-edit-key):
* lisp/erc/erc-backend.el (erc-server-processing-p)
(erc-split-line-length, erc-server-coding-system)
(erc-server-send, erc-message):
* lisp/erc/erc-button.el (erc-button-face, erc-button-alist)
(erc-browse-emacswiki):
* lisp/erc/erc-ezbounce.el (erc-ezbounce, erc-ezb-get-login):
* lisp/erc/erc-fill.el (erc-fill-variable-maximum-indentation):
* lisp/erc/erc-log.el (erc-current-logfile):
* lisp/erc/erc-match.el (erc-log-match-format)
(erc-text-matched-hook):
* lisp/erc/erc-netsplit.el (erc-netsplit, erc-netsplit-debug):
* lisp/erc/erc-networks.el (erc-server-alist)
(erc-networks-alist, erc-current-network):
* lisp/erc/erc-ring.el (erc-input-ring-index):
* lisp/erc/erc-speedbar.el (erc-speedbar)
(erc-speedbar-update-channel):
* lisp/erc/erc-stamp.el (erc-timestamp-only-if-changed-flag):
* lisp/erc/erc-track.el (erc-track-position-in-mode-line)
(erc-track-remove-from-mode-line, erc-modified-channels-update)
(erc-track-last-non-erc-buffer, erc-track-sort-by-importance)
(erc-track-get-active-buffer):
* lisp/erc/erc.el (erc-get-channel-user-list)
(erc-echo-notice-hook, erc-echo-notice-always-hook)
(erc-wash-quit-reason, erc-format-@nick):
* lisp/ffap.el (ffap-latex-mode):
* lisp/files.el (abort-if-file-too-large)
(dir-locals--get-sort-score, buffer-stale--default-function):
* lisp/filesets.el (filesets-tree-max-level, filesets-data)
(filesets-update-pre010505):
* lisp/gnus/gnus-agent.el (gnus-agent-flush-cache):
* lisp/gnus/gnus-art.el (gnus-article-encrypt-protocol)
(gnus-button-prefer-mid-or-mail):
* lisp/gnus/gnus-cus.el (gnus-group-parameters):
* lisp/gnus/gnus-demon.el (gnus-demon-handlers)
(gnus-demon-run-callback):
* lisp/gnus/gnus-dired.el (gnus-dired-print):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-event-from-buffer):
* lisp/gnus/gnus-range.el (gnus-range-normalize):
* lisp/gnus/gnus-spec.el (gnus-pad-form):
* lisp/gnus/gnus-srvr.el (gnus-server-agent, gnus-server-cloud)
(gnus-server-opened, gnus-server-closed, gnus-server-denied)
(gnus-server-offline):
* lisp/gnus/gnus-sum.el (gnus-refer-thread-use-nnir)
(gnus-refer-thread-limit-to-thread)
(gnus-summary-limit-include-thread, gnus-summary-refer-thread)
(gnus-summary-find-matching):
* lisp/gnus/gnus-util.el (gnus-rescale-image):
* lisp/gnus/gnus.el (gnus-summary-line-format, gnus-no-server):
* lisp/gnus/mail-source.el (mail-source-incoming-file-prefix):
* lisp/gnus/message.el (message-cite-reply-position)
(message-cite-style-outlook, message-cite-style-thunderbird)
(message-cite-style-gmail, message--send-mail-maybe-partially):
* lisp/gnus/mm-extern.el (mm-inline-external-body):
* lisp/gnus/mm-partial.el (mm-inline-partial):
* lisp/gnus/mml-sec.el (mml-secure-message-sign)
(mml-secure-message-sign-encrypt, mml-secure-message-encrypt):
* lisp/gnus/mml2015.el (mml2015-epg-key-image)
(mml2015-epg-key-image-to-string):
* lisp/gnus/nndiary.el (nndiary-reminders, nndiary-get-new-mail):
* lisp/gnus/nnheader.el (nnheader-directory-files-is-safe):
* lisp/gnus/nnir.el (nnir-search-history)
(nnir-imap-search-other, nnir-artlist-length)
(nnir-artlist-article, nnir-artitem-group, nnir-artitem-number)
(nnir-artitem-rsv, nnir-article-group, nnir-article-number)
(nnir-article-rsv, nnir-article-ids, nnir-categorize)
(nnir-retrieve-headers-override-function)
(nnir-imap-default-search-key, nnir-hyrex-additional-switches)
(gnus-group-make-nnir-group, nnir-run-namazu, nnir-read-parms)
(nnir-read-parm, nnir-read-server-parm, nnir-search-thread):
* lisp/gnus/nnmairix.el (nnmairix-default-group)
(nnmairix-propagate-marks):
* lisp/gnus/smime.el (smime-keys, smime-crl-check)
(smime-verify-buffer, smime-noverify-buffer):
* lisp/gnus/spam-report.el (spam-report-url-ping-mm-url):
* lisp/gnus/spam.el (spam-spamassassin-positive-spam-flag-header)
(spam-spamassassin-spam-status-header, spam-sa-learn-rebuild)
(spam-classifications, spam-check-stat, spam-spamassassin-score):
* lisp/help.el (describe-minor-mode-from-symbol):
* lisp/hippie-exp.el (hippie-expand-ignore-buffers):
* lisp/htmlfontify.el (hfy-optimizations, hfy-face-resolve-face)
(hfy-begin-span):
* lisp/ibuf-ext.el (ibuffer-update-saved-filters-format)
(ibuffer-saved-filters, ibuffer-old-saved-filters-warning)
(ibuffer-filtering-qualifiers, ibuffer-repair-saved-filters)
(eval, ibuffer-unary-operand, file-extension, directory):
* lisp/image-dired.el (image-dired-cmd-pngcrush-options):
* lisp/image-mode.el (image-toggle-display):
* lisp/international/ccl.el (ccl-compile-read-multibyte-character)
(ccl-compile-write-multibyte-character):
* lisp/international/kkc.el (kkc-save-init-file):
* lisp/international/latin1-disp.el (latin1-display):
* lisp/international/ogonek.el (ogonek-name-encoding-alist)
(ogonek-information, ogonek-lookup-encoding)
(ogonek-deprefixify-region):
* lisp/isearch.el (isearch-filter-predicate)
(isearch--momentary-message):
* lisp/jsonrpc.el (jsonrpc-connection-send)
(jsonrpc-process-connection, jsonrpc-shutdown)
(jsonrpc--async-request-1):
* lisp/language/tibet-util.el (tibetan-char-p):
* lisp/mail/feedmail.el (feedmail-queue-use-send-time-for-date)
(feedmail-last-chance-hook, feedmail-before-fcc-hook)
(feedmail-send-it-immediately-wrapper, feedmail-find-eoh):
* lisp/mail/hashcash.el (hashcash-generate-payment)
(hashcash-generate-payment-async, hashcash-insert-payment)
(hashcash-verify-payment):
* lisp/mail/rmail.el (rmail-movemail-variant-in-use)
(rmail-get-attr-value):
* lisp/mail/rmailmm.el (rmail-mime-prefer-html, rmail-mime):
* lisp/mail/rmailsum.el (rmail-summary-show-message):
* lisp/mail/supercite.el (sc-raw-mode-toggle):
* lisp/man.el (Man-start-calling):
* lisp/mh-e/mh-acros.el (mh-do-at-event-location)
(mh-iterate-on-messages-in-region, mh-iterate-on-range):
* lisp/mh-e/mh-alias.el (mh-alias-system-aliases)
(mh-alias-reload, mh-alias-ali)
(mh-alias-canonicalize-suggestion, mh-alias-add-alias-to-file)
(mh-alias-add-alias):
* lisp/mouse.el (mouse-save-then-kill):
* lisp/net/browse-url.el (browse-url-default-macosx-browser):
* lisp/net/eudc.el (eudc-set, eudc-variable-protocol-value)
(eudc-variable-server-value, eudc-update-variable)
(eudc-expand-inline):
* lisp/net/eudcb-bbdb.el (eudc-bbdb-format-record-as-result):
* lisp/net/eudcb-ldap.el (eudc-ldap-get-field-list):
* lisp/net/pop3.el (pop3-list):
* lisp/net/soap-client.el (soap-namespace-put)
(soap-xs-parse-sequence, soap-parse-envelope):
* lisp/net/soap-inspect.el (soap-inspect-xs-complex-type):
* lisp/nxml/rng-xsd.el (rng-xsd-date-to-days):
* lisp/org/ob-C.el (org-babel-prep-session:C)
(org-babel-load-session:C):
* lisp/org/ob-J.el (org-babel-execute:J):
* lisp/org/ob-asymptote.el (org-babel-prep-session:asymptote):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* lisp/org/ob-core.el (org-babel-process-file-name):
* lisp/org/ob-ebnf.el (org-babel-execute:ebnf):
* lisp/org/ob-forth.el (org-babel-execute:forth):
* lisp/org/ob-fortran.el (org-babel-execute:fortran)
(org-babel-prep-session:fortran, org-babel-load-session:fortran):
* lisp/org/ob-groovy.el (org-babel-execute:groovy):
* lisp/org/ob-io.el (org-babel-execute:io):
* lisp/org/ob-js.el (org-babel-execute:js):
* lisp/org/ob-lilypond.el (org-babel-default-header-args:lilypond)
(org-babel-lilypond-compile-post-tangle)
(org-babel-lilypond-display-pdf-post-tangle)
(org-babel-lilypond-tangle)
(org-babel-lilypond-execute-tangled-ly)
(org-babel-lilypond-compile-lilyfile)
(org-babel-lilypond-check-for-compile-error)
(org-babel-lilypond-process-compile-error)
(org-babel-lilypond-mark-error-line)
(org-babel-lilypond-parse-error-line)
(org-babel-lilypond-attempt-to-open-pdf)
(org-babel-lilypond-attempt-to-play-midi)
(org-babel-lilypond-switch-extension)
(org-babel-lilypond-set-header-args):
* lisp/org/ob-lua.el (org-babel-prep-session:lua):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-processing.el (org-babel-prep-session:processing):
* lisp/org/ob-python.el (org-babel-prep-session:python):
* lisp/org/ob-scheme.el (org-babel-scheme-capture-current-message)
(org-babel-scheme-execute-with-geiser, org-babel-execute:scheme):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/org-agenda.el (org-agenda-entry-types)
(org-agenda-move-date-from-past-immediately-to-today)
(org-agenda-time-grid, org-agenda-sorting-strategy)
(org-agenda-filter-by-category, org-agenda-forward-block):
* lisp/org/org-colview.el (org-columns--overlay-text):
* lisp/org/org-faces.el (org-verbatim, org-cycle-level-faces):
* lisp/org/org-indent.el (org-indent-set-line-properties):
* lisp/org/org-macs.el (org-get-limited-outline-regexp):
* lisp/org/org-mobile.el (org-mobile-files):
* lisp/org/org.el (org-use-fast-todo-selection)
(org-extend-today-until, org-use-property-inheritance)
(org-refresh-effort-properties, org-open-at-point-global)
(org-track-ordered-property-with-tag, org-shiftright):
* lisp/org/ox-html.el (org-html-checkbox-type):
* lisp/org/ox-man.el (org-man-source-highlight)
(org-man-verse-block):
* lisp/org/ox-publish.el (org-publish-sitemap-default):
* lisp/outline.el (outline-head-from-level):
* lisp/progmodes/dcl-mode.el (dcl-back-to-indentation-1)
(dcl-calc-command-indent, dcl-indent-to):
* lisp/progmodes/flymake.el (flymake-make-diagnostic)
(flymake--overlays, flymake-diagnostic-functions)
(flymake-diagnostic-types-alist, flymake--backend-state)
(flymake-is-running, flymake--collect, flymake-mode):
* lisp/progmodes/gdb-mi.el (gdb-threads-list, gdb, gdb-non-stop)
(gdb-buffers, gdb-gud-context-call, gdb-jsonify-buffer):
* lisp/progmodes/grep.el (grep-error-screen-columns):
* lisp/progmodes/gud.el (gud-prev-expr):
* lisp/progmodes/ps-mode.el (ps-mode, ps-mode-target-column)
(ps-run-goto-error):
* lisp/progmodes/python.el (python-eldoc-get-doc)
(python-eldoc-function-timeout-permanent, python-eldoc-function):
* lisp/shadowfile.el (shadow-make-group):
* lisp/speedbar.el (speedbar-obj-do-check):
* lisp/textmodes/flyspell.el (flyspell-auto-correct-previous-hook):
* lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib):
* lisp/textmodes/reftex-index.el (reftex-index-goto-entry)
(reftex-index-kill, reftex-index-undo):
* lisp/textmodes/reftex-parse.el (reftex-context-substring):
* lisp/textmodes/reftex.el (reftex-TeX-master-file):
* lisp/textmodes/rst.el (rst-next-hdr, rst-toc)
(rst-uncomment-region, rst-font-lock-extend-region-internal):
* lisp/thumbs.el (thumbs-mode):
* lisp/vc/ediff-util.el (ediff-restore-diff):
* lisp/vc/pcvs-defs.el (cvs-cvsroot, cvs-force-dir-tag):
* lisp/vc/vc-hg.el (vc-hg--ignore-patterns-valid-p):
* lisp/wid-edit.el (widget-field-value-set, string):
* lisp/x-dnd.el (x-dnd-version-from-flags)
(x-dnd-more-than-3-from-flags): Assorted docfixes.
2019-09-20 22:27:53 +00:00
|
|
|
respectively. This function first attempts to use pre-calculated
|
2006-11-10 08:54:38 +00:00
|
|
|
data from `calendar-dst-transition-cache', otherwise it calls
|
2007-04-17 02:29:50 +00:00
|
|
|
`calendar-dst-find-data' (and adds the results to the cache).
|
2019-02-11 07:47:43 +00:00
|
|
|
If dates in YEAR cannot be handled by `encode-time' (e.g.,
|
|
|
|
if they are out of range for POSIX time_t), then rather
|
2007-04-17 02:29:50 +00:00
|
|
|
than an error this function returns the result appropriate for
|
|
|
|
the current year."
|
2006-11-10 08:54:38 +00:00
|
|
|
(let ((e (assoc year calendar-dst-transition-cache))
|
|
|
|
f)
|
|
|
|
(or e
|
|
|
|
(progn
|
2007-04-17 02:29:50 +00:00
|
|
|
(setq e (calendar-dst-find-data
|
|
|
|
(condition-case nil
|
|
|
|
(encode-time 1 0 0 1 1 year)
|
|
|
|
(error
|
2019-07-30 11:06:06 +00:00
|
|
|
(encode-time 1 0 0 1 1
|
|
|
|
(decoded-time-year (decode-time))))))
|
2006-11-10 08:54:38 +00:00
|
|
|
f (nth 4 e)
|
|
|
|
e (list year f (nth 5 e))
|
|
|
|
calendar-dst-transition-cache
|
|
|
|
(append calendar-dst-transition-cache (list e)))
|
|
|
|
e))))
|
|
|
|
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(defun calendar-current-time-zone ()
|
|
|
|
"Return UTC difference, dst offset, names and rules for current time zone.
|
|
|
|
|
(calendar-time-zone-daylight-rules): Scan through the
next few years until at most one rule remains; if none remain, then
just use the first candidate rule; it's wrong in general, but it's
right for at least one year. This is a better heuristic in case the
underlying time zone implementation has bugs (which is all too
common). If possible, don't convert back and forth between gregorian
and absolute; this speeds things up noticeably. This uses the new
calendar-nth-named-absday function.
(calendar-current-time-zone): Some locales start DST at a different
time of day than they end; allow for this by yielding both times. The
performance speedups in calendar.el are great enough that we now no
longer need the "Checking time zone data..." message. If
current-time-zone yields nil, don't bother with
calendar-next-time-zone-transition. Use clearer names for local vars.
(calendar-time-zone, calendar-daylight-time-offset,
calendar-{standard,daylight}-time-zone-name,
calendar-daylight-savings-{starts,ends}): Default to US Eastern rules
for information that is not available.
(calendar-daylight-savings-{starts,ends}-time): New vars, replacing
calendar-daylight-savings-switchover-time, to support locales that
start DST at a different time of day than they end.
(calendar-absolute-from-time):
Fix typo by interchanging floor and mod.
1993-08-28 04:14:25 +00:00
|
|
|
Returns (UTC-DIFF DST-OFFSET STD-ZONE DST-ZONE DST-STARTS DST-ENDS
|
|
|
|
DST-STARTS-TIME DST-ENDS-TIME), based on a heuristic probing of what the
|
|
|
|
system knows:
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
UTC-DIFF is an integer specifying the number of minutes difference between
|
|
|
|
standard time in the current time zone and Coordinated Universal Time
|
|
|
|
(Greenwich Mean Time). A negative value means west of Greenwich.
|
2007-03-17 17:49:59 +00:00
|
|
|
DST-OFFSET is an integer giving the daylight saving time offset in minutes.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
STD-ZONE is a string giving the name of the time zone when no seasonal time
|
|
|
|
adjustment is in effect.
|
|
|
|
DST-ZONE is a string giving the name of the time zone when there is a seasonal
|
|
|
|
time adjustment in effect.
|
|
|
|
DST-STARTS and DST-ENDS are sexps in the variable `year' giving the daylight
|
2007-03-17 17:49:59 +00:00
|
|
|
saving time start and end rules, in the form expected by
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
`calendar-daylight-savings-starts'.
|
(calendar-time-zone-daylight-rules): Scan through the
next few years until at most one rule remains; if none remain, then
just use the first candidate rule; it's wrong in general, but it's
right for at least one year. This is a better heuristic in case the
underlying time zone implementation has bugs (which is all too
common). If possible, don't convert back and forth between gregorian
and absolute; this speeds things up noticeably. This uses the new
calendar-nth-named-absday function.
(calendar-current-time-zone): Some locales start DST at a different
time of day than they end; allow for this by yielding both times. The
performance speedups in calendar.el are great enough that we now no
longer need the "Checking time zone data..." message. If
current-time-zone yields nil, don't bother with
calendar-next-time-zone-transition. Use clearer names for local vars.
(calendar-time-zone, calendar-daylight-time-offset,
calendar-{standard,daylight}-time-zone-name,
calendar-daylight-savings-{starts,ends}): Default to US Eastern rules
for information that is not available.
(calendar-daylight-savings-{starts,ends}-time): New vars, replacing
calendar-daylight-savings-switchover-time, to support locales that
start DST at a different time of day than they end.
(calendar-absolute-from-time):
Fix typo by interchanging floor and mod.
1993-08-28 04:14:25 +00:00
|
|
|
DST-STARTS-TIME and DST-ENDS-TIME are integers giving the number of minutes
|
2007-03-17 17:49:59 +00:00
|
|
|
after midnight that daylight saving time starts and ends.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
(calendar-time-zone-daylight-rules): Scan through the
next few years until at most one rule remains; if none remain, then
just use the first candidate rule; it's wrong in general, but it's
right for at least one year. This is a better heuristic in case the
underlying time zone implementation has bugs (which is all too
common). If possible, don't convert back and forth between gregorian
and absolute; this speeds things up noticeably. This uses the new
calendar-nth-named-absday function.
(calendar-current-time-zone): Some locales start DST at a different
time of day than they end; allow for this by yielding both times. The
performance speedups in calendar.el are great enough that we now no
longer need the "Checking time zone data..." message. If
current-time-zone yields nil, don't bother with
calendar-next-time-zone-transition. Use clearer names for local vars.
(calendar-time-zone, calendar-daylight-time-offset,
calendar-{standard,daylight}-time-zone-name,
calendar-daylight-savings-{starts,ends}): Default to US Eastern rules
for information that is not available.
(calendar-daylight-savings-{starts,ends}-time): New vars, replacing
calendar-daylight-savings-switchover-time, to support locales that
start DST at a different time of day than they end.
(calendar-absolute-from-time):
Fix typo by interchanging floor and mod.
1993-08-28 04:14:25 +00:00
|
|
|
If the local area does not use a seasonal time adjustment, STD-ZONE and
|
|
|
|
DST-ZONE are equal, and all the DST-* integer variables are 0.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
Some operating systems cannot provide all this information to Emacs; in this
|
|
|
|
case, `calendar-current-time-zone' returns a list containing nil for the data
|
|
|
|
it can't find."
|
2012-06-28 12:13:38 +00:00
|
|
|
(or calendar-current-time-zone-cache
|
|
|
|
(setq calendar-current-time-zone-cache (calendar-dst-find-data))))
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
|
|
|
|
;; Following options should be set based on conditions when the code
|
|
|
|
;; is invoked, so are not suitable for dumping into loaddefs.el. They
|
|
|
|
;; default to US Eastern time if time zone info is not available.
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
|
|
|
(calendar-current-time-zone)
|
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
(defcustom calendar-time-zone (or (car calendar-current-time-zone-cache) -300)
|
2008-03-08 20:41:30 +00:00
|
|
|
"Number of minutes difference between local standard time and UTC.
|
2008-03-07 05:13:00 +00:00
|
|
|
For example, -300 for New York City, -480 for Los Angeles."
|
|
|
|
:type 'integer
|
|
|
|
:group 'calendar-dst)
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
(defcustom calendar-daylight-time-offset
|
2008-03-14 03:38:38 +00:00
|
|
|
(or (cadr calendar-current-time-zone-cache) 60)
|
2008-03-07 05:13:00 +00:00
|
|
|
"Number of minutes difference between daylight saving and standard time.
|
|
|
|
If the locale never uses daylight saving time, set this to 0."
|
|
|
|
:type 'integer
|
|
|
|
:group 'calendar-dst)
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
(defcustom calendar-standard-time-zone-name
|
2020-08-09 10:34:23 +00:00
|
|
|
(if calendar-use-numeric-time-zones
|
|
|
|
(if calendar-current-time-zone-cache
|
|
|
|
(format-time-string
|
|
|
|
"%z" 0 (* 60 (car calendar-current-time-zone-cache)))
|
|
|
|
"+0000")
|
|
|
|
(or (nth 2 calendar-current-time-zone-cache) "EST"))
|
2008-03-07 05:13:00 +00:00
|
|
|
"Abbreviated name of standard time zone at `calendar-location-name'.
|
|
|
|
For example, \"EST\" in New York City, \"PST\" for Los Angeles."
|
|
|
|
:type 'string
|
2020-08-09 10:34:23 +00:00
|
|
|
:version "28.1"
|
2008-03-07 05:13:00 +00:00
|
|
|
:group 'calendar-dst)
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
|
2008-03-07 05:13:00 +00:00
|
|
|
(defcustom calendar-daylight-time-zone-name
|
2020-08-09 10:34:23 +00:00
|
|
|
(if calendar-use-numeric-time-zones
|
|
|
|
(if calendar-current-time-zone-cache
|
|
|
|
(format-time-string
|
|
|
|
"%z" 0 (* 60 (cadr calendar-current-time-zone-cache)))
|
|
|
|
"+0000")
|
|
|
|
(or (nth 3 calendar-current-time-zone-cache) "EDT"))
|
2008-03-07 05:13:00 +00:00
|
|
|
"Abbreviated name of daylight saving time zone at `calendar-location-name'.
|
|
|
|
For example, \"EDT\" in New York City, \"PDT\" for Los Angeles."
|
|
|
|
:type 'string
|
2020-08-09 10:34:23 +00:00
|
|
|
:version "28.1"
|
2008-03-07 05:13:00 +00:00
|
|
|
:group 'calendar-dst)
|
|
|
|
|
|
|
|
(defcustom calendar-daylight-savings-starts-time
|
2008-03-14 03:38:38 +00:00
|
|
|
(or (nth 6 calendar-current-time-zone-cache) 120)
|
2008-03-07 05:13:00 +00:00
|
|
|
"Number of minutes after midnight that daylight saving time starts."
|
|
|
|
:type 'integer
|
|
|
|
:group 'calendar-dst)
|
|
|
|
|
|
|
|
(defcustom calendar-daylight-savings-ends-time
|
2008-03-14 03:38:38 +00:00
|
|
|
(or (nth 7 calendar-current-time-zone-cache)
|
2008-03-07 05:13:00 +00:00
|
|
|
calendar-daylight-savings-starts-time)
|
|
|
|
"Number of minutes after midnight that daylight saving time ends."
|
|
|
|
:type 'integer
|
|
|
|
:group 'calendar-dst)
|
2003-02-04 13:24:35 +00:00
|
|
|
|
2006-11-10 08:54:38 +00:00
|
|
|
|
|
|
|
(defun calendar-dst-starts (year)
|
2007-03-17 17:49:59 +00:00
|
|
|
"Return the date of YEAR on which daylight saving time starts.
|
2006-11-10 08:54:38 +00:00
|
|
|
This function respects the value of `calendar-dst-check-each-year-flag'."
|
|
|
|
(or (let ((expr (if calendar-dst-check-each-year-flag
|
|
|
|
(cadr (calendar-dst-find-startend year))
|
|
|
|
(nth 4 calendar-current-time-zone-cache))))
|
2017-12-04 20:50:14 +00:00
|
|
|
(calendar-dlet* ((year year))
|
|
|
|
(if expr (eval expr))))
|
2017-09-13 22:52:52 +00:00
|
|
|
;; New US rules commencing 2007. https://www.iana.org/time-zones
|
2006-11-10 08:54:38 +00:00
|
|
|
(and (not (zerop calendar-daylight-time-offset))
|
2006-12-24 02:58:41 +00:00
|
|
|
(calendar-nth-named-day 2 0 3 year))))
|
2006-11-10 08:54:38 +00:00
|
|
|
|
|
|
|
(defun calendar-dst-ends (year)
|
2007-03-17 17:49:59 +00:00
|
|
|
"Return the date of YEAR on which daylight saving time ends.
|
2006-11-10 08:54:38 +00:00
|
|
|
This function respects the value of `calendar-dst-check-each-year-flag'."
|
|
|
|
(or (let ((expr (if calendar-dst-check-each-year-flag
|
|
|
|
(nth 2 (calendar-dst-find-startend year))
|
|
|
|
(nth 5 calendar-current-time-zone-cache))))
|
2017-12-04 20:50:14 +00:00
|
|
|
(calendar-dlet* ((year year))
|
|
|
|
(if expr (eval expr))))
|
2017-09-13 22:52:52 +00:00
|
|
|
;; New US rules commencing 2007. https://www.iana.org/time-zones
|
2006-11-10 08:54:38 +00:00
|
|
|
(and (not (zerop calendar-daylight-time-offset))
|
2006-12-24 02:58:41 +00:00
|
|
|
(calendar-nth-named-day 1 0 11 year))))
|
2006-11-10 08:54:38 +00:00
|
|
|
|
2008-04-11 03:43:55 +00:00
|
|
|
;; used by calc, solar.
|
1995-09-21 02:54:58 +00:00
|
|
|
(defun dst-in-effect (date)
|
2007-03-17 17:49:59 +00:00
|
|
|
"True if on absolute DATE daylight saving time is in effect.
|
1995-12-05 22:55:22 +00:00
|
|
|
Fractional part of DATE is local standard time of day."
|
2017-12-04 20:50:14 +00:00
|
|
|
(calendar-dlet* ((year (calendar-extract-year
|
|
|
|
(calendar-gregorian-from-absolute (floor date)))))
|
|
|
|
(let* ((dst-starts-gregorian (eval calendar-daylight-savings-starts))
|
|
|
|
(dst-ends-gregorian (eval calendar-daylight-savings-ends))
|
|
|
|
(dst-starts (and dst-starts-gregorian
|
|
|
|
(+ (calendar-absolute-from-gregorian
|
|
|
|
dst-starts-gregorian)
|
|
|
|
(/ calendar-daylight-savings-starts-time
|
|
|
|
60.0 24.0))))
|
|
|
|
(dst-ends (and dst-ends-gregorian
|
1995-09-21 02:54:58 +00:00
|
|
|
(+ (calendar-absolute-from-gregorian
|
2017-12-04 20:50:14 +00:00
|
|
|
dst-ends-gregorian)
|
|
|
|
(/ (- calendar-daylight-savings-ends-time
|
|
|
|
calendar-daylight-time-offset)
|
|
|
|
60.0 24.0)))))
|
|
|
|
(and dst-starts dst-ends
|
|
|
|
(if (< dst-starts dst-ends)
|
|
|
|
(and (<= dst-starts date) (< date dst-ends))
|
|
|
|
(or (<= dst-starts date) (< date dst-ends)))))))
|
1995-09-21 02:54:58 +00:00
|
|
|
|
2008-04-11 03:43:55 +00:00
|
|
|
;; used by calc, lunar, solar.
|
2011-04-19 04:11:01 +00:00
|
|
|
(defun dst-adjust-time (date time)
|
1995-09-21 02:54:58 +00:00
|
|
|
"Adjust, to account for dst on DATE, decimal fraction standard TIME.
|
|
|
|
Returns a list (date adj-time zone) where `date' and `adj-time' are the values
|
|
|
|
adjusted for `zone'; here `date' is a list (month day year), `adj-time' is a
|
|
|
|
decimal fraction time, and `zone' is a string.
|
|
|
|
|
2007-03-17 17:49:59 +00:00
|
|
|
Conversion to daylight saving time is done according to
|
1995-09-21 02:54:58 +00:00
|
|
|
`calendar-daylight-savings-starts', `calendar-daylight-savings-ends',
|
|
|
|
`calendar-daylight-savings-starts-time',
|
2008-03-26 03:10:23 +00:00
|
|
|
`calendar-daylight-savings-ends-time', and `calendar-daylight-time-offset'."
|
1995-09-21 02:54:58 +00:00
|
|
|
(let* ((rounded-abs-date (+ (calendar-absolute-from-gregorian date)
|
2008-03-13 06:29:28 +00:00
|
|
|
(/ (round (* 60 time)) 60.0 24.0)))
|
1995-09-21 02:54:58 +00:00
|
|
|
(dst (dst-in-effect rounded-abs-date))
|
2008-03-13 06:29:28 +00:00
|
|
|
(time-zone (if dst
|
|
|
|
calendar-daylight-time-zone-name
|
|
|
|
calendar-standard-time-zone-name))
|
|
|
|
(time (+ rounded-abs-date
|
1995-09-21 02:54:58 +00:00
|
|
|
(if dst (/ calendar-daylight-time-offset 24.0 60.0) 0))))
|
|
|
|
(list (calendar-gregorian-from-absolute (truncate time))
|
|
|
|
(* 24.0 (- time (truncate time)))
|
|
|
|
time-zone)))
|
|
|
|
|
* cal-dst.el: New file.
(calendar-/, calendar-%, calendar-absolute-from-time,
calendar-time-from-absolute, calendar-next-time-zone-transition,
calendar-time-zone-daylight-rules): New functions.
(calendar-current-time-zone): Moved from calendar.el and rewritten.
(calendar-current-time-zone-cache): New variable.
(calendar-current-time-zone, calendar-time-zone,
calendar-daylight-time-offset, calendar-standard-time-zone-name,
calendar-daylight-time-zone-name,
calendar-daylight-savings-starts, calendar-daylight-savings-ends,
calendar-daylight-savings-switchover-time): Moved from calendar.el.
1993-06-22 03:25:13 +00:00
|
|
|
(provide 'cal-dst)
|
|
|
|
|
|
|
|
;;; cal-dst.el ends here
|