Repository navigation
into datetime: accept duration as input - #19402
Conversation
There was a problem hiding this comment.
Review overview
🟢 A few small things
Durations work as input on the default path, with --offset, --timezone and cell paths, and at both ends of the duration range. What's left is small: two error messages, a list signature, a few tests and the release note.
Findings: 0
Open (5)
Notes from my clanker, checked on 39c3916. Built the branch and ran each case on the branch binary and on 0.116.2 (c302d6f). CI already ran fmt, clippy and the tests on Linux, macOS and Windows for this head, so I didn't rerun them.
|
What's the advantage of this over: 1614434140123 * 1000000 | into datetime
# => Sat, 27 Feb 2021 13:55:40 +0000 (5 years ago)or for duration based modifications to the Unix epoch: (0 | into datetime) + 1wk
# => Thu, 8 Jan 1970 00:00:00 +0000 (56 years ago) |
39c3916 to
cff9385
Compare
|
Ok I think I got all the review comments. For testing, I've added to the unit tests within the same file, rather than the integration tests. |
Sorry, is this a serious question you want answered .... ? Working with rich types is clearer and less error-prone than working with raw numbers. No thinking about how many zeros to convert the timestamp into nanoseconds, or even having to know or care that the internal representation of a datetime or a duration is a nanosecond. One may as well ask what the advantage is of having a distinct duration type at all, when one could just convert to and from ints. |
There was a problem hiding this comment.
Review overview
🟢 A few small things
3 of the 5 threads are fixed and resolved: the --format error, the fallback error text and the list<duration> signature. Two are left. The new offset tests can't see a dropped offset and a few cases still have no test, and the release notes section is still empty.
Findings: 0
Open (2)
Notes from my clanker, checked on 7c5045b. Built the branch and ran probe.sh and recheck.sh on it and on main (4492226). Ran the datetime unit tests with the Zone::East and Zone::Local arms changed to return UTC (20 passed), then restored the file. CI is green on this head (11 checks), so I didn't rerun the full test suite, clippy or fmt locally.
|
please respond to each review comment so we can make sure nothing is missed |
Ok sure, I just replied to the two still open. When the review comments are clearly AI-generated, it's not very clear what you, as the human, actually want, and what is just AI noise. |
ya, this one was a mess. sorry about that. i'm kind of the lone ranger here sometimes. it's a lot to keep up with. |
|
These are the remaining things we need looked at.
These four still have no test. Please add these to tests somewhere. -1day | into datetime | to nuon # 1969-12-31T00:00:00+00:00
1sec | into datetime --offset -5 | to nuon # 1969-12-31T19:00:01-05:00
1sec | into datetime --timezone Europe/Berlin | to nuon # 1970-01-01T01:00:01+01:00
{a: 1sec} | into datetime a | to nuon # {a: 1970-01-01T00:00:01+00:00}The first three fit as
If the
I'm not asking to change assert_eq!(actual.as_date().unwrap().offset().local_minus_utc(), 8 * 3600); |
68e08bf to
6e1e062
Compare
|
Ok, I think I got everything remaining. |
Durations can be interpreted the same way as plain ints, i.e., as a unix timestamp.
6e1e062 to
287beea
Compare
|
Thanks |



Description
Durations can now be given as input to
into datetime; they are interpreted as Unix seconds. This makes it easier to convert ints into datetimes when they represent Unix timestamps in units other than seconds, e.g.User-facing changes (Release notes)
Durations can now be given as input to
into datetime; they are interpreted as Unix seconds. This makes it easier to convert ints into datetimes when they represent Unix timestamps in units other than seconds, e.g.Additional notes