'decoded-time-weekday', 'decoded-time-dst' and 'decoded-time-zone'
accessors can be used.
-+++
*** The new functions 'date-days-in-month' (which will say how many
days there are in a month in a specific year), 'date-ordinal-to-time'
(that computes the date of an ordinal day), 'decoded-time-add' for
-doing computations on a decoded time structure), and
-'make-decoded-time' (for making a decoded time structure with only the
-given keywords filled out) have been added.
+doing computations on a decoded time structure), 'make-decoded-time'
+(for making a decoded time structure with only the given keywords
+filled out), and 'encoded-time-set-defaults' (which fills in nil
+elements as if it's midnight January 1st, 1970) have been added.
** 'define-minor-mode' automatically documents the meaning of ARG.
(defun iso8601--encode-time (time)
"Like `encode-time', but fill in nil values in TIME."
- (setq time (copy-sequence time))
- (unless (decoded-time-second time)
- (setf (decoded-time-second time) 0))
- (unless (decoded-time-minute time)
- (setf (decoded-time-minute time) 0))
- (unless (decoded-time-hour time)
- (setf (decoded-time-hour time) 0))
-
- (unless (decoded-time-day time)
- (setf (decoded-time-day time) 1))
- (unless (decoded-time-month time)
- (setf (decoded-time-month time) 1))
- (unless (decoded-time-year time)
- (setf (decoded-time-year time) 0))
- (encode-time time))
+ (encode-time (decoded-time-set-defaults (copy-sequence time))))
(provide 'iso8601)
"Return a `decoded-time' structure with only the keywords given filled out."
(list second minute hour day month year nil dst zone))
+(defun decoded-time-set-defaults (time)
+ "Set any nil values in `decoded-time' TIME to default values.
+The default value is based on January 1st, 1970 at midnight.
+
+TIME is modified and returned."
+ (unless (decoded-time-second time)
+ (setf (decoded-time-second time) 0))
+ (unless (decoded-time-minute time)
+ (setf (decoded-time-minute time) 0))
+ (unless (decoded-time-hour time)
+ (setf (decoded-time-hour time) 0))
+
+ (unless (decoded-time-day time)
+ (setf (decoded-time-day time) 1))
+ (unless (decoded-time-month time)
+ (setf (decoded-time-month time) 1))
+ (unless (decoded-time-year time)
+ (setf (decoded-time-year time) 0))
+ time)
+
(provide 'time-date)
;;; time-date.el ends here