Live data from Hacker News

Jiff: Datetime library for Rust

github.com

41–50 of 249 posts

Re: Jiff: Datetime library for Rust

#41
post #6

A 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…

What I gather about the author's thoughts about that, he isn't a fan of copyright in general, and uses UNLICENSE as an ideological statement, plus a practical way of saying "do whatever you want with this", but also slaps the option to use MIT as "something almost as good" because non-standard licenses deter corporate types, which kind of defeats the original "do whatever you want" purpose of UNLICENSE :D

That's what I gather from Unlicense too (in fact, this is confirmed in a linked bug thread where the author says he "hates copyright").

I think the author is actually looking for the GPL but doesn't realise it yet. Unlicense can't make something free forever, no matter how hard the author wishes it. GPL can. In other words, Unlicense/MIT is idealistic, GPL is pragmatic. You can't turn off copyright, but you can make it work for the people instead of against them.

Re: Jiff: Datetime library for Rust

#42

Overall 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.

Yeah, or there could simply be a `days()` free function (and equivalents of the other methods too). No need for struct constructors to be associated functions.

Re: Jiff: Datetime library for Rust

#43

This looks like a cool library. Does anyone know why burntsushi is making this new library? I haven't messed around with times in rust much, but do the existing libraries have performance problems? Or are the existing API's awkward to use? Or is he just doing it for fun, or some other reason?

[flagged]

Re: Jiff: Datetime library for Rust

#44
post #31

Earlier 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…

All of these options work and are equivalent. - let time = Timestamp::parse("2024-07-11T01:14:00Z")?; - let time: Timestamp = "2024-07-11T01:14:00Z".parse()?; - let time = "2024-07-11T01:14:00Z".parse:: ()?; You’re free to choose whatever you prefer, although the compiler needs to be able to infer the type of time. If it can’t, it’ll let you know. So a fourth option is allowed, as long as the subsequent lines make th…

  let time = Timestamp::from_str("2024-07-11T01:14:00Z")?;
I think you meant :)

Re: Jiff: Datetime library for Rust

#45

This looks like a cool library. Does anyone know why burntsushi is making this new library? I haven't messed around with times in rust much, but do the existing libraries have performance problems? Or are the existing API's awkward to use? Or is he just doing it for fun, or some other reason?

Linked from the readme:

https://github.com/BurntSushi/jiff/blob/master/DESIGN.md

https://github.com/BurntSushi/jiff/blob/master/COMPARE.md

TLDR: API and IANA timezone support primarily.

Re: Jiff: Datetime library for Rust

#46
post #32

Earlier quoted context omitted.

I remember getting into a debate with him on Reddit about something or other and then realizing who I was debating with and saying never mind.

That shouldn't stop you from settling an argument (given it was respectful). The best way to learn is to be wronged by smarter people.

Also, just because someone is famous/important/etc doesn't mean they're always right. In fact, one of the dangerous things about being famous is the people stop being willing to disagree with you and that can lead to becoming detached and warped as a person.

Re: Jiff: Datetime library for Rust

#48
post #32

Earlier quoted context omitted.

I remember getting into a debate with him on Reddit about something or other and then realizing who I was debating with and saying never mind.

That shouldn't stop you from settling an argument (given it was respectful). The best way to learn is to be wronged by smarter people.

I feel very certain that's not the best way to learn.

Re: Jiff: Datetime library for Rust

#49
The fact that we need a such complicated datetime library just means so many unncessary artificial complexities were introduced before (yes the daylight saving, leap seconds etc.)

Re: Jiff: Datetime library for Rust

#50

Earlier quoted context omitted.

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.

Kind of inefficient. Also it's less ergonomic since every struct is it's own type, so you need to have the signature on both sides.

It should compile to the same because a struct passed by value is loaded into the registers the same as method arguments.
Post reply on HN