aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/time-stamp.el20
-rw-r--r--test/lisp/time-stamp-tests.el19
2 files changed, 37 insertions, 2 deletions
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 094ef915265..6b1ff3e618c 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."
109 :type '(choice (const :tag "Emacs local time" nil) 109 :type '(choice (const :tag "Emacs local time" nil)
110 (const :tag "Universal Time" t) 110 (const :tag "Universal Time" t)
111 (const :tag "system wall clock time" wall) 111 (const :tag "system wall clock time" wall)
112 (string :tag "TZ environment variable value")) 112 (string :tag "TZ environment variable value")
113 (list :tag "Offset and name"
114 (integer :tag "Offset (seconds east of UTC)")
115 (string :tag "Time zone abbreviation"))
116 (integer :tag "Offset (seconds east of UTC)"))
113 :group 'time-stamp 117 :group 'time-stamp
114 :version "20.1") 118 :version "20.1")
115;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable 'string-or-null-p) 119;;;###autoload(put 'time-stamp-time-zone 'safe-local-variable 'time-stamp-zone-type-p)
120
121;;;###autoload
122(defun time-stamp-zone-type-p (zone)
123 "Return whether or not ZONE is of the correct type for a timezone rule.
124Valid ZONE values are described in the documentation of `format-time-string'."
125 (or (memq zone '(nil t wall))
126 (stringp zone)
127 (and (consp zone)
128 (integerp (car zone))
129 (consp (cdr zone))
130 (stringp (cadr zone)))
131 (integerp zone)))
116 132
117;;; Do not change time-stamp-line-limit, time-stamp-start, 133;;; Do not change time-stamp-line-limit, time-stamp-start,
118;;; time-stamp-end, time-stamp-pattern, time-stamp-inserts-lines, 134;;; 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 92df1839350..ad2cb0ead7f 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -57,6 +57,8 @@
57 57
58;;; Tests: 58;;; Tests:
59 59
60;;; Tests of time-stamp-string formatting
61
60(ert-deftest time-stamp-test-format-day-of-week () 62(ert-deftest time-stamp-test-format-day-of-week ()
61 "Test time-stamp formats for named day of week." 63 "Test time-stamp formats for named day of week."
62 (with-time-stamp-test-env 64 (with-time-stamp-test-env
@@ -360,4 +362,21 @@
360 (should (equal (time-stamp-string "%#3a" ref-time3) "SUN")) 362 (should (equal (time-stamp-string "%#3a" ref-time3) "SUN"))
361 (should (equal (time-stamp-string "%#3b" ref-time2) "NOV")))) 363 (should (equal (time-stamp-string "%#3b" ref-time2) "NOV"))))
362 364
365;;; Tests of helper functions
366
367(ert-deftest time-stamp-test-helper-zone-type-p ()
368 "Test time-stamp-zone-type-p."
369 (should (time-stamp-zone-type-p t))
370 (should (time-stamp-zone-type-p nil))
371 (should (time-stamp-zone-type-p 'wall))
372 (should-not (time-stamp-zone-type-p 'floor))
373 (should (time-stamp-zone-type-p "arbitrary string"))
374 (should (time-stamp-zone-type-p 0))
375 (should-not (time-stamp-zone-type-p 3.14))
376 (should-not (time-stamp-zone-type-p '(0)))
377 (should-not (time-stamp-zone-type-p '(0 . "A")))
378 (should (time-stamp-zone-type-p '(0 "A")))
379 (should-not (time-stamp-zone-type-p '(0 0)))
380 (should-not (time-stamp-zone-type-p '("A" "A"))))
381
363;;; time-stamp-tests.el ends here 382;;; time-stamp-tests.el ends here