Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

Jiff 1.0: A datetime library for Rust (https://burntsushi.net)

443 points by burntsushi 4 days ago | 102 comments | View on ycombinator

quodlibetor 4 days ago |

I maintained chrono for about half a decade, and the specific reason I took on maintenance was because the API sucked and I hoped I could make it better.

Turns out, the reason people wanted to use it was because the API was stable and every slight step towards improvement was met with... resistance. I stopped maintaining it because the burnout from seeing what it could be and not seeing any path to get there was too much for me.

I'm extremely grateful to burntsushi for writing the datetime library rust deserves. Chrono is stable and is maintained (though semi-deprecated) by an extremely reliable rustacean -- you don't need to leave, but you'll probably be happier if you do.

Dagonfly 4 days ago |

> When should I use Jiff? Jiff isn’t always the right thing to use.

I really appreciate when a project calmly acknowledges that it's not the right tool for every use case, and is not trying to be. That's professional engineering.

Especially in the AI-age, the crucial skill will be what NOT to implement.

mgrandl 4 days ago |

It’s so good like all the other burntsushi libs. Really hope it will be adopted more and more by the wider ecosystem over chrono and co.

ddahlen 4 days ago |

This looks interesting!

Time is such a pain, I write code for simulating orbits of asteroids/stuff in the solar system, and time and time conversions play a major roll in it. I often need accuracy at the mega-year to giga-year scales, but also sometimes micro-second relative.

I saw on this page that you at least mention TAI time, how are you handling time scales in general? Like would it be hard to add some other timescales like UT1?

Right now I have to do all of this manually and I have been using chrono as just a convenience wrapper so that my users can convert ISO time strings into my internal representation.

Edit: Oh no! I just found out chrono is being semi-deprecated, looks like I'm going to be switching...

Sebb767 3 days ago |

From [0]:

> Unlike “Comparison with other Rust datetime crates,” this document is opinionated. > [...] > Jiff is pronounced like “gif” with a soft “g,” as in “gem.”

Burntsushi really did not hold back with this document being opinionated :-) (Though they are right, of course).

[0] https://docs.rs/jiff/latest/jiff/_documentation/design/index...

pbrowne011 4 days ago |

Nice! I appreciated the documentation for tzdb on avoiding embedding and the thought process behind using "rearguard" data [1]. Some related GitHub issues are also worth reading [2] [3].

[1] https://docs.rs/jiff-tzdb/latest/jiff_tzdb/#data-generation

[2] https://github.com/BurntSushi/jiff/issues/278

[3] https://github.com/BurntSushi/jiff/issues/279

the__alchemist 4 days ago |

I will give this a shot, however... Rust is the only language I've used where I want to use the established one, chrono. I will roll my own in JS, for example, or begrudgingly use or wrap the python.datetime one (And not touch the third party python ones which do awful things inspired by Moment.js like conflating dates , times, and datetimes, under the guise dates and times don't have use on their own), but Chrono actually is comparatively nice (S-tier relative to others), both std and no_std.

poulpy123 4 days ago |

I would have expected a modern language to have an extensive datetime library in its standard library

tadhunt 2 days ago |

With a chance it'll be helpful to Golang devs https://github.com/tadhunt/datetime makes similar decisions as Jiff, but goes a bit further to also handle times lacking precision (missing year, month and TOD known, DOM not, etc).

AI wrote it under my strict design parameters. We use it in production in a high volume event production company, PRs welcome!

kjuulh 4 days ago |

Jiff is very nice to work with. It is always a pleasure working with something crafted by burntsushi

brianwitte 4 days ago |

the jiff pronunciation meta got my brain working hard for second. love it

robrain 4 days ago |

tiffanyh 3 days ago |

For anyone who doesn’t appreciate his hard it is to develop a datetime library, watch this great short video by Tom Scott

https://youtu.be/-5wpm-gesOY?is=uTBX7FlDPNaUt7oC

undefined 2 days ago |

undefined

Sytten 3 days ago |

I did the chrono 0.1 -> time 0.3 -> chrono 0.4 dance, hopefully jiff is the last. I need to add support for it in diesel if not already. Pretty sure we have corners of llrt where we still use chrono.

undefined 4 days ago |

undefined

i2talics 4 days ago |

IME time is one of those things that a lot of developers try to wish away the complexity. The hard part is defining what you even mean by time, but if nobody asks the question then you don't have to provide an answer.

Strings are also similarly gnarly topic that I find a lot of devs try to ignore.

fstephany 4 days ago |

Jiff will probably be the default datetime library for a lot of Rustaceans (and LLMs) in the years to come.

Thank you for your work on this burntsushi!

Sparkle-san 4 days ago |

> Jiff is pronounced like “gif” with a soft “g,” as in “gem.”

Woah now, let's not get too controversial.

arjie 4 days ago |

My favourite part about BurntSushi software was that the structure of the program was enough that even a novice at the language could change things. Very well laid out. I had a fork of many of his applications for personal use and it was always trivial to jump in and edit. Excellent stuff.

> Jiff is pronounced like “gif” with a soft “g,” as in “gem.”

This is classic anti-trust monopoly leveraging. Lucky I'm on this side of the debate :)

dizzant 3 days ago |

> Jiff is pronounced like “gif” with a soft “g,” as in “gem.”

A masterclass in viral outrage bait. Not a Rustacean, I clicked the link exclusively for this nugget and will probably tell my Rust-loving colleagues about it tomorrow.

For the record, I like the converse better:

> Jiff is pronounced with a hard “g”, as in “gif”.

kodebach 3 days ago |

Always fascinating how some languages still struggle with datetime stuff, when Java (or the JVM in general) basically solved it over a decade ago. And I say "solved" because everything seems to eventually settle on the same API as java.time.

gosen 4 days ago |

I thought it's the right moment to finally do something with Rust, but I work on my "J" pronunciation first

echelon 3 days ago |

> Jiff is pronounced like “gif” with a soft “g,” as in “gem.”

What a cardinal sin! Instantly distrust this project.

(I'm kidding, Andrew. But this is clearly the wrong pronunciation! :P)

NetOpWibby 4 days ago |

Love seeing the correct pronunciation of gif

undefined 4 days ago |

undefined

PowerElectronix 4 days ago |

Weird, you can't ever pronounce Jiff as gif.

Levitating 3 days ago |

Looks like great software.

BetterThanSober 3 days ago |

Time is so intuitive to us humans (mostly) yet feels so excruciatingly complicated to manipulate in computer

I really, really, hate Monday

kccqzy 3 days ago |

The one thing I don’t like in most datetime libraries is that for timezone names they all just defer to IANA time zone database. This database is a wonderful compendium of all time zones historically in use, but it is absolutely programmer oriented and not user oriented. There are two main problems: (1) it’s based on large cities; (2) it captures history faithfully.

The first problem is the bigger problem. If you are writing an app that asks the user for a zoned time, the user will want something like Nov 16 7pm eastern time. But EST is of course highly ambiguous and so is EDT. (The database actually gives EST to Panama Time and leaves EDT undefined.) The correct solution is either EST5EDT or America/New_York. Neither is user friendly. The first string EST5EDT looks like gibberish to the average user. The second raises concerns in all other cities sharing the same timezone as New York. Why not have an entry for Philadelphia or Washington D.C.? Some even say it is inherently classist to pick the city with the biggest population, not the most important by some other metric. Is New York more deserving than our nation’s political capital? Why is Los Angeles more deserving than San Francisco, other than the fact that the maintainer of the database is physically in Los Angeles? This is an actual criticism in iOS calendar app on the now defunct Apple forums. If you want the user to pick a timezone you better make sure Eastern Time is an allowed option, and maybe also include all the cities and municipalities in the zone; that’s what the newest iOS does. But in any case almost every developer now hard codes a mapping from Eastern Time to America/New_York if their audience is U.S. This feels like duplicative work better done in a library. The fact that a new library reaches 1.0 and doesn’t plan to add this might mean a lack of ambition to tackle this problem.

The second problem is the fact that the timezone definitions change according to the actual rules in effect in history. This is sometimes not what you want. Indeed I notice that most if not all date libraries use the proleptic Gregorian calendar (our current calendar system extended backwards); no library that I know of automatically switches to Julian calendars before the cutoff. Why this inconsistency? I’d argue that when most humans express a zoned time they expect the current rules to be extended backwards. People forget the daylight saving rules change in the 2000s when talking about times before that change and expect the current rules.

Not to be a detractor here for this library given the hard work of burntsushi, but we should aim higher.

3ph3m3re 3 days ago |

As a rust hobbyist coming from Java, I feel a bit sad that there is no standard library for date handling like java.time API.

Do you seasoned rustaceans may explain why we don’t have such a standard library?

It’s a genuine question from an ignorant :)

amai 2 days ago |

Imagine a world without daylight saving time... How many IT issues could have been avoided.

Taiizor 3 days ago |

[flagged]

jheriko 4 days ago |

[dead]

undefined 4 days ago |

undefined