Function: gnus-search-imap-handle-date

gnus-search-imap-handle-date is a byte-compiled function defined in gnus-search.el.gz.

Signature

(gnus-search-imap-handle-date ARG0 ARG &rest ARGS)

Implementations

((engine gnus-search-imap) (date list)) in `gnus-search.el'.

Turn DATE into a date string recognizable by IMAP. While other search engines can interpret partially-qualified dates such as a plain "January", IMAP requires an absolute date.

DATE is a list of (dd mm yyyy), any element of which could be nil (except that (dd nil yyyy) is not allowed). Massage those numbers into the most recent past occurrence of whichever date elements are present.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-search.el.gz
(cl-defmethod gnus-search-imap-handle-date ((_engine gnus-search-imap)
					    (date list))
  "Turn DATE into a date string recognizable by IMAP.
While other search engines can interpret partially-qualified
dates such as a plain \"January\", IMAP requires an absolute
date.

DATE is a list of (dd mm yyyy), any element of which could be
nil (except that (dd nil yyyy) is not allowed).  Massage those
numbers into the most recent past occurrence of whichever date
elements are present."
  (pcase-let ((`(,nday ,nmonth ,nyear)
	       (seq-subseq (decode-time (current-time))
			   3 6))
	      (`(,dday ,dmonth ,dyear) date))
    (unless (and dday dmonth dyear)
      (unless dday (setq dday 1))
      (if dyear
	  ;; If we have a year, then leave everything else as is or set
	  ;; to 1.
	  (setq dmonth (or dmonth 1))
	(if dmonth
	    (setq dyear
		  (if (or (> dmonth nmonth)
			  (and (= dmonth nmonth)
			       (> dday nday)))
		      ;; If our day/month combo is ahead of "now",
		      ;; move the year back.
		      (1- nyear)
		    nyear))
	  (setq dmonth 1))))
    (format-time-string
     "%e-%b-%Y"
     (apply #'encode-time
	    (append '(0 0 0)
		    (list dday dmonth dyear))))))