1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-17 11:20:39 -08:00

* lisp/simple.el (decoded-time): Use cl-defstruct

This commit is contained in:
Stefan Monnier 2019-07-29 11:57:49 -04:00
parent 75361be63f
commit 5483e44730

View file

@ -9065,79 +9065,27 @@ to capitalize ARG words."
;;; Accessors for `decode-time' values. ;;; Accessors for `decode-time' values.
(defsubst decoded-time-second (time) (cl-defstruct (decoded-time
"The seconds in TIME, which is a value returned by `decode-time'. (:constructor nil)
(:copier nil)
(:type list))
(second nil :documentation "\
This is an integer between 0 and 60 (inclusive). (60 is a leap This is an integer between 0 and 60 (inclusive). (60 is a leap
second, which only some operating systems support.)" second, which only some operating systems support.)")
(nth 0 time)) (minute nil :documentation "This is an integer between 0 and 59 (inclusive).")
(hour nil :documentation "This is an integer between 0 and 23 (inclusive).")
(defsubst decoded-time-minute (time) (day nil :documentation "This is an integer between 1 and 31 (inclusive).")
"The minutes in TIME, which is a value returned by `decode-time'. (month nil :documentation "\
This is an integer between 0 and 59 (inclusive)." This is an integer between 1 and 12 (inclusive). January is 1.")
(nth 1 time)) (year nil :documentation "This is a four digit integer.")
(weekday nil :documentation "\
(defsubst decoded-time-hour (time) This is a number between 0 and 6, and 0 is Sunday.")
"The hours in TIME, which is a value returned by `decode-time'. (dst nil :documentation "\
This is an integer between 0 and 23 (inclusive)." This is t if daylight saving time is in effect, and nil if not.")
(nth 2 time)) (zone nil :documentation "\
(defsubst decoded-time-day (time)
"The day-of-the-month in TIME, which is a value returned by `decode-time'.
This is an integer between 1 and 31 (inclusive)."
(nth 3 time))
(defsubst decoded-time-month (time)
"The month in TIME, which is a value returned by `decode-time'.
This is an integer between 1 and 12 (inclusive). January is 1."
(nth 4 time))
(defsubst decoded-time-year (time)
"The year in TIME, which is a value returned by `decode-time'.
This is a four digit integer."
(nth 5 time))
(defsubst decoded-time-weekday (time)
"The day-of-the-week in TIME, which is a value returned by `decode-time'.
This is a number between 0 and 6, and 0 is Sunday."
(nth 6 time))
(defsubst decoded-time-dst (time)
"The daylight saving time in TIME, which is a value returned by `decode-time'.
This is t if daylight saving time is in effect, and nil if not."
(nth 7 time))
(defsubst decoded-time-zone (time)
"The time zone in TIME, which is a value returned by `decode-time'.
This is an integer indicating the UTC offset in seconds, i.e., This is an integer indicating the UTC offset in seconds, i.e.,
the number of seconds east of Greenwich." the number of seconds east of Greenwich.")
(nth 8 time)) )
(gv-define-setter decoded-time-second (second time)
`(setf (nth 0 ,time) ,second))
(gv-define-setter decoded-time-minute (minute time)
`(setf (nth 1 ,time) ,minute))
(gv-define-setter decoded-time-hour (hour time)
`(setf (nth 2 ,time) ,hour))
(gv-define-setter decoded-time-day (day time)
`(setf (nth 3 ,time) ,day))
(gv-define-setter decoded-time-month (month time)
`(setf (nth 4 ,time) ,month))
(gv-define-setter decoded-time-year (year time)
`(setf (nth 5 ,time) ,year))
;; No setter for weekday, which is the 6th element.
(gv-define-setter decoded-time-dst (dst time)
`(setf (nth 7 ,time) ,dst))
(gv-define-setter decoded-time-zone (zone time)
`(setf (nth 8 ,time) ,zone))