Skip to content

Instantly share code, notes, and snippets.

@peccu
Created November 6, 2015 05:40
Show Gist options
  • Save peccu/a9e5611e4e6d4a9be281 to your computer and use it in GitHub Desktop.
Save peccu/a9e5611e4e6d4a9be281 to your computer and use it in GitHub Desktop.
Mewのサマリモードで、タイムゾーンを考慮した日時を表示する
;; mew summary date/time considering timezone
;; http://permalink.gmane.org/gmane.mail.mew.general.japanese/2355
(defun mew-summary-form-time-z ()
"A function to return a message time, HH:MM"
(let ((s (MEW-DATE)))
(setq s (timezone-make-date-arpa-standard
(if (or (string= s "")
(not (string-match mew-time-rfc-regex s)))
(mew-time-ctz-to-rfc
(mew-file-get-time (mew-expand-folder (MEW-FLD) (MEW-NUM))))
s)))
(if (string-match mew-time-rfc-regex s)
(format "%02d:%02d"
(or (mew-time-rfc-hour) 0)
(or (mew-time-rfc-min) 0))
"00:00")))
(defun mew-summary-form-date-z ()
"A function to return a date, MM/DD."
(let ((s (MEW-DATE)))
(setq s (timezone-make-date-arpa-standard
(if (or (string= s "")
(not (string-match mew-time-rfc-regex s)))
(mew-time-ctz-to-rfc
(mew-file-get-time (mew-expand-folder (MEW-FLD) (MEW-NUM))))
s)))
(if (string-match mew-time-rfc-regex s)
(format "%02d/%02d"
(mew-time-mon-str-to-int (mew-time-rfc-mon))
(mew-time-rfc-day))
"")))
(defun mew-summary-form-time-zone ()
"A function to return a message date timezone, +ZZZZ."
(let ((s (MEW-DATE)))
(when (or (string= s "")
(not (string-match mew-time-rfc-regex s)))
(setq s (mew-time-ctz-to-rfc
(mew-file-get-time (mew-expand-msg (MEW-FLD) (MEW-NUM))))))
(if (string-match mew-time-rfc-regex s)
(format "%05s"
(if (match-beginning 9)
(let ((tmzn (substring s (match-beginning 9) (match-end 9)))
int)
(cond
((string-match "^[-+][0-9]+$" tmzn)
tmzn)
((setq int (mew-time-tmzn-str-to-int tmzn))
(format "%s00" int))
(t "+????")))
"+????"))
"+????")))
;; use above
;; (setq mew-summary-form '(type (4 year) "/" (5 date-z) " " (5 time-z) "(" (5 time-zone) ") " (60 from) "|" t (0 subj)))
@yuichish
Copy link

これを参考に mew の環境を整えました。ありがとうございます。
使っていてバグに気付きました。
(mew-expand-folder (MEW-FLD) (MEW-NUM)) が2箇所ありますが、これは
(mew-expand-msg (MEW-FLD) (MEW-NUM)) の間違いだと思います。

@yasuoka
Copy link

yasuoka commented Apr 22, 2021

大変便利です。emacs-27.2 にして気づいたのですが、timezone.el を require する必要があるようです。

(require 'timezone)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment