comparison lisp/gnus/gnus-util.el @ 108981:b7963ca9e06e

Synch with Gnus trunk. * gnus-util.el (gnus-date-get-time): Move up before first use.
author Romain Francoise <romain@orebokech.com>
date Sat, 12 Jun 2010 19:26:40 +0200
parents 234c5347118d
children f5fa348fd8eb
comparison
equal deleted inserted replaced
108980:c3dddc8e5767 108981:b7963ca9e06e
427 (let ((now (decode-time (current-time))) 427 (let ((now (decode-time (current-time)))
428 (days (format-time-string "%j" (current-time)))) 428 (days (format-time-string "%j" (current-time))))
429 (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) 429 (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)
430 (* (- (string-to-number days) 1) 3600 24)))) 430 (* (- (string-to-number days) 1) 3600 24))))
431 431
432 (defmacro gnus-date-get-time (date)
433 "Convert DATE string to Emacs time.
434 Cache the result as a text property stored in DATE."
435 ;; Either return the cached value...
436 `(let ((d ,date))
437 (if (equal "" d)
438 '(0 0)
439 (or (get-text-property 0 'gnus-time d)
440 ;; or compute the value...
441 (let ((time (safe-date-to-time d)))
442 ;; and store it back in the string.
443 (put-text-property 0 1 'gnus-time time d)
444 time)))))
445
432 (defvar gnus-user-date-format-alist 446 (defvar gnus-user-date-format-alist
433 '(((gnus-seconds-today) . "%k:%M") 447 '(((gnus-seconds-today) . "%k:%M")
434 (604800 . "%a %k:%M") ;;that's one week 448 (604800 . "%a %k:%M") ;;that's one week
435 ((gnus-seconds-month) . "%a %d") 449 ((gnus-seconds-month) . "%a %d")
436 ((gnus-seconds-year) . "%b %d") 450 ((gnus-seconds-year) . "%b %d")
477 (defun gnus-dd-mmm (messy-date) 491 (defun gnus-dd-mmm (messy-date)
478 "Return a string like DD-MMM from a big messy string." 492 "Return a string like DD-MMM from a big messy string."
479 (condition-case () 493 (condition-case ()
480 (format-time-string "%d-%b" (gnus-date-get-time messy-date)) 494 (format-time-string "%d-%b" (gnus-date-get-time messy-date))
481 (error " - "))) 495 (error " - ")))
482
483 (defmacro gnus-date-get-time (date)
484 "Convert DATE string to Emacs time.
485 Cache the result as a text property stored in DATE."
486 ;; Either return the cached value...
487 `(let ((d ,date))
488 (if (equal "" d)
489 '(0 0)
490 (or (get-text-property 0 'gnus-time d)
491 ;; or compute the value...
492 (let ((time (safe-date-to-time d)))
493 ;; and store it back in the string.
494 (put-text-property 0 1 'gnus-time time d)
495 time)))))
496 496
497 (defsubst gnus-time-iso8601 (time) 497 (defsubst gnus-time-iso8601 (time)
498 "Return a string of TIME in YYYYMMDDTHHMMSS format." 498 "Return a string of TIME in YYYYMMDDTHHMMSS format."
499 (format-time-string "%Y%m%dT%H%M%S" time)) 499 (format-time-string "%Y%m%dT%H%M%S" time))
500 500