From: Paul Eggert Date: Fri, 14 Sep 2018 00:31:58 +0000 (-0700) Subject: Simplify use of timestamps X-Git-Tag: emacs-27.0.90~4421 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=da4e5f668582e1f047b6bd5259a1a4f92b5461b6;p=emacs.git Simplify use of timestamps * lisp/calendar/icalendar.el (icalendar--create-uid): * lisp/gnus/nnmaildir.el (nnmaildir-request-accept-article): Simplify by using format-time-string. * lisp/gnus/nnmaildir.el (nnmaildir--scan): Simplify by using float-time and time-less-p. --- diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index c1a3e0a4213..e3e458a4dd7 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el @@ -1016,9 +1016,7 @@ current iCalendar object, as a string. Increase (setq icalendar--uid-count (1+ icalendar--uid-count)) (setq uid (replace-regexp-in-string "%t" - (format "%d%d%d" (car (current-time)) - (cadr (current-time)) - (car (cddr (current-time)))) + (format-time-string "%s%N") uid t t)) (setq uid (replace-regexp-in-string "%h" diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el index c8480ddda4c..48a470c7462 100644 --- a/lisp/gnus/nnmaildir.el +++ b/lisp/gnus/nnmaildir.el @@ -764,7 +764,7 @@ This variable is set by `nnmaildir-request-article'.") (defun nnmaildir--scan (gname scan-msgs groups _method srv-dir srv-ls) (catch 'return - (let ((36h-ago (- (car (current-time)) 2)) + (let ((36h-ago (- (float-time) 129600)) absdir nndir tdir ndir cdir nattr cattr isnew pgname read-only ls files num dir flist group x) (setq absdir (nnmaildir--srvgrp-dir srv-dir gname) @@ -801,7 +801,7 @@ This variable is set by `nnmaildir-request-article'.") (throw 'return nil)) (dolist (file (funcall ls tdir 'full "\\`[^.]" 'nosort)) (setq x (file-attributes file)) - (if (or (> (cadr x) 1) (< (car (nth 4 x)) 36h-ago)) + (if (or (> (cadr x) 1) (time-less-p (nth 4 x) 36h-ago)) (delete-file file)))) (or scan-msgs isnew @@ -1463,9 +1463,7 @@ This variable is set by `nnmaildir-request-article'.") (unless (string-equal nnmaildir--delivery-time file) (setq nnmaildir--delivery-time file nnmaildir--delivery-count 0)) - (when (and (consp (cdr time)) - (consp (cddr time))) - (setq file (concat file "M" (number-to-string (caddr time))))) + (setq file (concat file (format-time-string "M%6N" time))) (setq file (concat file nnmaildir--delivery-pid) file (concat file "Q" (number-to-string nnmaildir--delivery-count)) file (concat file "." (nnmaildir--system-name))