all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Decoded time accessors
@ 2019-07-07 19:33 Lars Ingebrigtsen
  2019-07-07 19:52 ` Paul Eggert
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Lars Ingebrigtsen @ 2019-07-07 19:33 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-07-29 12:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-07 19:33 Decoded time accessors Lars Ingebrigtsen
2019-07-07 19:52 ` Paul Eggert
2019-07-07 20:09   ` Lars Ingebrigtsen
2019-07-07 21:43 ` Alan Mackenzie
2019-07-07 22:20   ` Lars Ingebrigtsen
2019-07-07 22:25   ` Clément Pit-Claudel
2019-07-08 14:41   ` Eli Zaretskii
2019-07-09  0:12   ` Accessor functions vs nth (WAS: Decoded time accessors) Noam Postavsky
2019-07-10 10:02     ` João Távora
2019-07-29 12:29 ` Decoded time accessors Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.