Function: gnus-search-query-parse-date
gnus-search-query-parse-date is a byte-compiled function defined in
gnus-search.el.gz.
Signature
(gnus-search-query-parse-date VALUE &optional REL-DATE)
Documentation
Interpret VALUE as a date specification.
See the docstring of gnus-search-parse-query for details.
The result is a list of (dd mm yyyy); individual elements can be nil.
If VALUE is a relative time, interpret it as relative to REL-DATE, or (current-time) if REL-DATE is nil.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/gnus-search.el.gz
(defun gnus-search-query-parse-date (value &optional rel-date)
"Interpret VALUE as a date specification.
See the docstring of `gnus-search-parse-query' for details.
The result is a list of (dd mm yyyy); individual elements can be
nil.
If VALUE is a relative time, interpret it as relative to
REL-DATE, or (current-time) if REL-DATE is nil."
;; Time parsing doesn't seem to work with slashes.
(let ((value (string-replace "/" "-" value))
(now (append '(0 0 0)
(seq-subseq (decode-time (or rel-date
(current-time)))
3))))
;; Check for relative time parsing.
(if (string-match "\\([[:digit:]]+\\)\\([dwmy]\\)" value)
(seq-subseq
(decode-time
(time-subtract
(apply #'encode-time now)
(days-to-time
(* (string-to-number (match-string 1 value))
(cdr (assoc (match-string 2 value)
'(("d" . 1)
("w" . 7)
("m" . 30)
("y" . 365))))))))
3 6)
;; Otherwise check the value of `parse-time-string'.
;; (SEC MIN HOUR DAY MON YEAR DOW DST TZ)
(let ((d-time (parse-time-string value)))
;; Did parsing produce anything at all?
(if (seq-some #'integerp (seq-subseq d-time 3 7))
(seq-subseq
;; If DOW is given, handle that specially.
(if (and (seq-elt d-time 6) (null (seq-elt d-time 3)))
(decode-time
(time-subtract (apply #'encode-time now)
(days-to-time
(+ (if (> (seq-elt d-time 6)
(seq-elt now 6))
7 0)
(- (seq-elt now 6) (seq-elt d-time 6))))))
d-time)
3 6)
;; `parse-time-string' failed to produce anything, just
;; return the string.
value)))))