From 3c728d4c69f2abe991ef84787ae1014ad1cd29d2 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 9 Aug 2020 12:34:23 +0200 Subject: [PATCH] Add a variable to allow displaying numeric time zones * lisp/calendar/calendar.el (calendar-use-numeric-time-zones): New variable. * doc/emacs/calendar.texi (Sunrise/Sunset): Document it (bug#33149). * lisp/calendar/cal-dst.el (calendar-standard-time-zone-name): Use it. (calendar-daylight-time-zone-name): Ditto. * lisp/calendar/solar.el (sunrise-sunset): Adjust usage. (solar-equinoxes-solstices): Ditto. --- doc/emacs/calendar.texi | 5 +++++ etc/NEWS | 7 +++++++ lisp/calendar/cal-dst.el | 16 ++++++++++++++-- lisp/calendar/calendar.el | 7 +++++++ lisp/calendar/solar.el | 9 +++++++-- 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi index fe51ad35d77..31db815df70 100644 --- a/doc/emacs/calendar.texi +++ b/doc/emacs/calendar.texi @@ -625,6 +625,11 @@ your time zone. Emacs displays the times of sunrise and sunset @emph{corrected for daylight saving time}. @xref{Daylight Saving}, for how daylight saving time is determined. +@vindex calendar-use-numeric-time-zones + If you want to display numerical time zones (like @samp{"+0100"}) +instead of symbolic time zones (like @samp{"CET"}), set the +@code{calendar-use-numeric-time-zones} variable to non-@code{nil}. + As a user, you might find it convenient to set the calendar location variables for your usual physical location in your @file{.emacs} file. If you are a system administrator, you may want to set these variables diff --git a/etc/NEWS b/etc/NEWS index 71c037631af..2f204a5b4bc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -194,6 +194,13 @@ The presence of a space between an open paren and a symbol now is taken as a statement by the programmer that this should be indented as a data list rather than as a piece of code. +** Calendar + +*** New variable 'calendar-use-numeric-time-zones' to use numeric time zones. +If non-nil, functions that display time zones (like the 'S' command in +calendar mode that displays the sunrise time) will display time zones +like "+0100" instead of "CET". + ** Dired *** New user option 'dired-mark-region' affects all Dired commands diff --git a/lisp/calendar/cal-dst.el b/lisp/calendar/cal-dst.el index 3db12e668ab..af6acaf09ad 100644 --- a/lisp/calendar/cal-dst.el +++ b/lisp/calendar/cal-dst.el @@ -350,17 +350,29 @@ If the locale never uses daylight saving time, set this to 0." :group 'calendar-dst) (defcustom calendar-standard-time-zone-name - (or (nth 2 calendar-current-time-zone-cache) "EST") + (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")) "Abbreviated name of standard time zone at `calendar-location-name'. For example, \"EST\" in New York City, \"PST\" for Los Angeles." :type 'string + :version "28.1" :group 'calendar-dst) (defcustom calendar-daylight-time-zone-name - (or (nth 3 calendar-current-time-zone-cache) "EDT") + (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")) "Abbreviated name of daylight saving time zone at `calendar-location-name'. For example, \"EDT\" in New York City, \"PDT\" for Los Angeles." :type 'string + :version "28.1" :group 'calendar-dst) (defcustom calendar-daylight-savings-starts-time diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el index 1d5b9479e2b..9a6c78a50eb 100644 --- a/lisp/calendar/calendar.el +++ b/lisp/calendar/calendar.el @@ -1061,6 +1061,13 @@ calendar." :type 'boolean :group 'holidays) +(defcustom calendar-use-numeric-time-zones nil + "If nil, use symbolic time zones like \"CET\" when displaying dates. +If non-nil, use numeric time zines like \"+0100\"." + :type 'boolean + :version "28.1" + :group 'calendar) + ;;; End of user options. (calendar-recompute-layout-variables) diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index 6a813e9ee82..20a20df4603 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el @@ -840,7 +840,9 @@ This function is suitable for execution in an init file." "E" "W")))))) (calendar-standard-time-zone-name (if (< arg 16) calendar-standard-time-zone-name - (cond ((zerop calendar-time-zone) "UTC") + (cond ((zerop calendar-time-zone) + (if calendar-use-numeric-time-zones + "+0100" "UTC")) ((< calendar-time-zone 0) (format "UTC%dmin" calendar-time-zone)) (t (format "UTC+%dmin" calendar-time-zone))))) @@ -1013,7 +1015,10 @@ Requires floating point." (let* ((m displayed-month) (y displayed-year) (calendar-standard-time-zone-name - (if calendar-time-zone calendar-standard-time-zone-name "UTC")) + (cond + (calendar-time-zone calendar-standard-time-zone-name) + (calendar-use-numeric-time-zones "+0100") + (t "UTC"))) (calendar-daylight-savings-starts (if calendar-time-zone calendar-daylight-savings-starts)) (calendar-daylight-savings-ends -- 2.39.2