[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Decoded time accessors
From: |
Lars Ingebrigtsen |
Subject: |
Decoded time accessors |
Date: |
Sun, 07 Jul 2019 21:33:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
A while back we added accessors to the return value from
`file-attributes' (i.e., `file-attribute-size' etc), and I think that
was a readability win.
I think we should do the same for the return value for `decode-time',
but do it as settable values instead:
---
decode-time is a built-in function in ‘C source code’.
(decode-time &optional TIME ZONE)
Probably introduced at or before Emacs version 19.29.
This function does not change global state, including the match data.
Decode a time value as (SEC MINUTE HOUR DAY MONTH YEAR DOW DST UTCOFF).
---
So you could do something like
(let ((decoded (decode-time (parse-time-string ...))))
(setf (decoded-time-year decoded) 1975)
(apply #'encode-time decoded))
or whatever. I hate reading code that says (elt decoded 5) and then
have to look up the doc string and then count to be able to tell what
it's doing...
Does this sound like a good idea? And if so, what should the name of
these accessors be? `decoded-time-' is clear, but perhaps a mouthful...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Decoded time accessors,
Lars Ingebrigtsen <=