From: tsuchiya Date: Fri, 12 Oct 2001 03:22:36 +0000 (+0000) Subject: (format-time-string): Support the construct `%z'. X-Git-Tag: apel-10_3-1~11 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97f5ef85b0cd85a26a41e05fbd61e78692c288d6;p=elisp%2Fapel.git (format-time-string): Support the construct `%z'. (support-timezone-in-numeric-form): New advice. --- diff --git a/ChangeLog b/ChangeLog index d120824..c9fe8e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-10-12 TSUCHIYA Masatoshi + + * poe.el (format-time-string): Support the construct `%z'. + (support-timezone-in-numeric-form): New advice. + 2001-09-09 Daiki Ueno * pccl.el (transform-make-coding-system-args): Follow old backquote diff --git a/poe.el b/poe.el index 5224803..d2a9309 100644 --- a/poe.el +++ b/poe.el @@ -1418,6 +1418,11 @@ Not fully compatible especially when invalid format is specified." ((eq cur-char ?Z) (setq change-case (not change-case)) (downcase (cadr (current-time-zone)))) + ((eq cur-char ?z) + (let ((tz (car (current-time-zone)))) + (if (< tz 0) + (format "-%02d%02d" (/ (- tz) 3600) (/ (% (- tz) 3600) 60)) + (format "+%02d%02d" (/ tz 3600) (/ (% tz 3600) 60))))) (t (concat "%" @@ -1459,6 +1464,24 @@ Not fully compatible especially when invalid format is specified." (setq current-load-list (cons 'format-time-string current-load-list)) (put 'format-time-string 'defun-maybe t)))) +;; Emacs 19.29-19.34/XEmacs: format-time-string() doesn't support `%z'. +(unless (string-match "\\`[\\-\\+][0-9]+\\'" + (format-time-string "%z" (current-time))) + (defadvice format-time-string + (before support-timezone-in-numeric-form activate compile) + "Advice to support the construct `%z'." + (if (let ((case-fold-search nil)) + (string-match "\\(\\(\\`\\|[^%]\\)\\(%%\\)*\\)%z" (ad-get-arg 0))) + (ad-set-arg + 0 + (concat + (substring (ad-get-arg 0) 0 (match-end 1)) + (let ((tz (car (current-time-zone)))) + (if (< tz 0) + (format "-%02d%02d" (/ (- tz) 3600) (/ (% (- tz) 3600) 60)) + (format "+%02d%02d" (/ tz 3600) (/ (% tz 3600) 60)))) + (substring (ad-get-arg 0) (match-end 0))))))) + ;; Emacs 20.1/XEmacs 20.3(?) and later: (split-string STRING &optional PATTERN) ;; Here is a XEmacs version. (defun-maybe split-string (string &optional pattern)