Jiff: Datetime library for Rust
21–30 of 249 posts
Re: Jiff: Datetime library for Rust
#22A little off topic but does anyone know the purpose of dual licensing MIT and the UNLICENSE? It seems like the second should already allow anyone to do whatever they want…
The unlicense is considered problematic in various jurisdictions, among them Germany - under German law, you cannot relinquish certain rights that are associated with the author at all. Dedicating something to the public domain is not a valid concept here. This means the whole license could be declared invalid in court. Other jurisdictions may be similarly problematic- thus the fallback to MIT There’s a stackoverflow…
(I collected that mostly because I didn’t find all the relevant information in one place, or explanation of the reasonable alternatives.)
Re: Jiff: Datetime library for Rust
#23Overall this looks nice, but I found myself stumbling over the ToSpan syntax: let span = 5.days().hours(8).minutes(1); It feels sort of weird how the first number appears in front, and then all the other ones are function arguments. I suppose if you don't like that you can just write: let span = Span::new().days(5).hours(8).minutes(1); at the expense of a couple characters, which is not too bad.
I stumbled over use jiff::{Timestamp, ToSpan}; fn main() -> Result { let time: Timestamp = "2024-07-11T01:14:00Z".parse()?; I seem to remember Rust does that thing with interfaces instead of classes, is it that? How come I import a library and all of a sudden strings have a `parse()` method that despite its generic name results in a `Timestamp` object? or is it the left-hand side that determines which meaning `str.pa…
> let time: Timestamp = "2024-07-11T01:14:00Z".parse::()?;
Re: Jiff: Datetime library for Rust
#24Earlier quoted context omitted.
If only Rust had named function parameters, you could write what is IMHO the most readable option: Span::new(days=5, hours=8, minutes=1)
could you do that with `struct` / `record` fields? In JavaScript which doesn't have named function parameters either I often write functions with a single `cfg` parameter that are called like `f({ hours: 2, seconds: 53, })` which I find nice b/c it re-uses existing data structures.
Re: Jiff: Datetime library for Rust
#25Re: Jiff: Datetime library for Rust
#26So, ist it pronounced jiff or gif?
Re: Jiff: Datetime library for Rust
#27Overall this looks nice, but I found myself stumbling over the ToSpan syntax: let span = 5.days().hours(8).minutes(1); It feels sort of weird how the first number appears in front, and then all the other ones are function arguments. I suppose if you don't like that you can just write: let span = Span::new().days(5).hours(8).minutes(1); at the expense of a couple characters, which is not too bad.
I agree. Personally, I'd prefer let span = 5.days() + 8.hours() + 1.minutes();
Re: Jiff: Datetime library for Rust
#28I've been dealing with time and timezones for a long time, but this is the first time I have ever seen the "[Olson/Name]" suffix. Is that actually standard?
I've seen it being used in ECMAScript's Temporal https://tc39.es/proposal-temporal/docs/strings.html
Now that I'm back at my desk I had to check ISO8601, that suffix is not included. However it does look like an extension - RFC 9557 - which looks like is still in proposed state.
I would personally caution using these suffixes until wider adoption, because AFAIK the Olson database names themselves are not standardised on non-POSIX systems (i.e you might have a hard time on Windows).
Re: Jiff: Datetime library for Rust
#29Earlier quoted context omitted.
If only Rust had named function parameters, you could write what is IMHO the most readable option: Span::new(days=5, hours=8, minutes=1)
could you do that with `struct` / `record` fields? In JavaScript which doesn't have named function parameters either I often write functions with a single `cfg` parameter that are called like `f({ hours: 2, seconds: 53, })` which I find nice b/c it re-uses existing data structures.
It would have to look something like:
f({ hours: 2, seconds: 53, ..Default::default() })
The defaults could come from some value / function with a name shorter than Default::default(), but it would be less clear.Re: Jiff: Datetime library for Rust
#30Earlier quoted context omitted.
I stumbled over use jiff::{Timestamp, ToSpan}; fn main() -> Result { let time: Timestamp = "2024-07-11T01:14:00Z".parse()?; I seem to remember Rust does that thing with interfaces instead of classes, is it that? How come I import a library and all of a sudden strings have a `parse()` method that despite its generic name results in a `Timestamp` object? or is it the left-hand side that determines which meaning `str.pa…
It's implied. Here is the full syntax. > let time: Timestamp = "2024-07-11T01:14:00Z".parse:: ()?;