Function: htz:date-sortable

htz:date-sortable is a byte-compiled function defined in htz.el.

Signature

(htz:date-sortable &optional DATE LOCAL TIMEZONE)

Documentation

Convert optional DATE or current date to a sortable date string.

Optional 1st argument LOCAL specifies the local timezone of the DATE. Optional 2nd argument TIMEZONE specifies an output timezone to use.

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/htz.el
(defun htz:date-sortable (&optional date local timezone)
  "Convert optional DATE or current date to a sortable date string.
Optional 1st argument LOCAL specifies the local timezone of the DATE.
Optional 2nd argument TIMEZONE specifies an output timezone to use."
  (or (vectorp date)
      (setq date (htz:date-parse (or date (current-time-string)))))
  (let* ((year   (string-to-number (aref date 0)))
	 (month  (string-to-number (aref date 1)))
	 (day    (string-to-number (aref date 2)))
	 (time   (htz:time-parse   (aref date 3)))
	 (hour   (string-to-number (aref time 0)))
	 (minute (string-to-number (aref time 1)))
	 (second (string-to-number (aref time 2)))
	 (local  (or (aref date 4) local htz:local)) ;Use original if defined
	 (timezone (or timezone local))
	 (diff   (- (htz:zone-to-hour timezone)
		    (htz:zone-to-hour local)))
	 (new    (htz:time-fix year month day
			       (+ hour diff) minute second)))
    (htz:date-make-sortable (aref new 0) (aref new 1) (aref new 2)
			    (htz:time-make-string
			     (aref new 3) (aref new 4) (aref new 5)))))