[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 113ff95: time-stamp-time-zone: update customization
From: |
Stephen Gildea |
Subject: |
master 113ff95: time-stamp-time-zone: update customization |
Date: |
Sun, 27 Oct 2019 11:21:51 -0400 (EDT) |
branch: master
commit 113ff954dbcd24325bd674b7294d54a7c8394d42
Author: Stephen Gildea <address@hidden>
Commit: Stephen Gildea <address@hidden>
time-stamp-time-zone: update customization
* time-stamp.el (time-stamp-time-zone): Support customization with
an integer offset (a new possible value of the ZONE argument to
format-time-string in Emacs 27).
Update the safe-local-variable predicate from string-or-null-p
(describing time-stamp-time-zone's domain before 2015) to new
predicate time-stamp-zone-type-p (describing the current domain).
* time-stamp-tests.el (time-stamp-test-helper-zone-type-p): New test.
---
lisp/time-stamp.el | 20 ++++++++++++++++++--
test/lisp/time-stamp-tests.el | 19 +++++++++++++++++++
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 094ef91..6b1ff3e 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -109,10 +109,26 @@ Its format is that of the ZONE argument of the
`format-time-string' function."
:type '(choice (const :tag "Emacs local time" nil)
(const :tag "Universal Time" t)
(const :tag "system wall clock time" wall)
- (string :tag "TZ environment variable value"))
+ (string :tag "TZ environment variable value")
+ (list :tag "Offset and name"
+ (integer :tag "Offset (seconds east of UTC)")
+ (string :tag "Time zone abbreviation"))
+ (integer :tag "Offset (seconds east of UTC)"))
:group 'time-stamp
:version "20.1")
-;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable
'string-or-null-p)
+;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable
'time-stamp-zone-type-p)
+
+;;;###autoload
+(defun time-stamp-zone-type-p (zone)
+ "Return whether or not ZONE is of the correct type for a timezone rule.
+Valid ZONE values are described in the documentation of `format-time-string'."
+ (or (memq zone '(nil t wall))
+ (stringp zone)
+ (and (consp zone)
+ (integerp (car zone))
+ (consp (cdr zone))
+ (stringp (cadr zone)))
+ (integerp zone)))
;;; Do not change time-stamp-line-limit, time-stamp-start,
;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines,
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 92df183..ad2cb0e 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -57,6 +57,8 @@
;;; Tests:
+;;; Tests of time-stamp-string formatting
+
(ert-deftest time-stamp-test-format-day-of-week ()
"Test time-stamp formats for named day of week."
(with-time-stamp-test-env
@@ -360,4 +362,21 @@
(should (equal (time-stamp-string "%#3a" ref-time3) "SUN"))
(should (equal (time-stamp-string "%#3b" ref-time2) "NOV"))))
+;;; Tests of helper functions
+
+(ert-deftest time-stamp-test-helper-zone-type-p ()
+ "Test time-stamp-zone-type-p."
+ (should (time-stamp-zone-type-p t))
+ (should (time-stamp-zone-type-p nil))
+ (should (time-stamp-zone-type-p 'wall))
+ (should-not (time-stamp-zone-type-p 'floor))
+ (should (time-stamp-zone-type-p "arbitrary string"))
+ (should (time-stamp-zone-type-p 0))
+ (should-not (time-stamp-zone-type-p 3.14))
+ (should-not (time-stamp-zone-type-p '(0)))
+ (should-not (time-stamp-zone-type-p '(0 . "A")))
+ (should (time-stamp-zone-type-p '(0 "A")))
+ (should-not (time-stamp-zone-type-p '(0 0)))
+ (should-not (time-stamp-zone-type-p '("A" "A"))))
+
;;; time-stamp-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 113ff95: time-stamp-time-zone: update customization,
Stephen Gildea <=