-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update internal to avoid precision destruction #27
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
test/test.el
Outdated
(should (and (consp (ts-internal (ts-now))) | ||
(not (proper-list-p (ts-internal (ts-now))))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to test this, we should probably ensure that each element is an integer, as intended. I'd probably use pcase
.
ts.el
Outdated
@@ -222,7 +222,7 @@ slot `year' and alias `y' would create an alias `ts-y')." | |||
;; MAYBE: Add tz-offset-minutes | |||
|
|||
(internal | |||
nil :accessor-init (apply #'encode-time (decode-time (ts-unix struct)))) | |||
nil :accessor-init (funcall #'time-convert (ts-unix struct) t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use funcall
instead of calling time-convert
directly?
Unless I missed something Minor aside, I couldn't find a way to use I don't quite understand the README selling point about |
Ok, I'm taking your word on that for now.
This package predates that and similar functions. If those functions had existed, I might not have written this library, or it might have been written as a thin wrapper around them. Nevertheless, I suspect this package may still have a performance advantage when only one or a few slots are needed, because it avoids decoding all slots. But I don't have time to re-benchmark the whole package against the latest date/time functions in current Emacs now. |
First things first regarding #25
I noticed while writing a test that
#'ts-apply
and `#'ts-update' were mutating the unix time even though it's unnecessary.A proper fix started to rabbit hole a bit:
ts-apply
with just a:unix
time, there's no need to update the unix time again ints-update
. Every other slot could update if non-nil, but the unix time should notThe kinds of tests I was running and expecting to work:
ts-update
is not taking the easy path...Here's another test
Ah, so both times are actually truncating to seconds unnecessarily. I can expand the scope of the PR if you think it's likely to pay off.