Does anyone know of any good literature on datetime arithmetic? Or perhaps a really good software library (standard or third-party)? Especially anything that tackles non-communitivity, overflows or nonexistant dates/times (due to timezone effects).

I'm looking to rehaul the stdlib datetime module soon, and we want it to be very robust and of high quality. Will also be helpful in some Hare projects, like a scheduler.

=> docs.harelang.org/datetime
=> git.sr.ht/~sircmpwn/scheduled

The closest thing to a useful standard I've found is this:

=> w3.org/TR/xmlschema-2/#adding-

In the mean time, I'm trying to create a formalisation of datetime arithmetic so we can have something theoretically sound to implement. Something which takes advantage of Hare's language features. If you're interested, let me know. The more gray matter, the better. Boosts welcome.

@torresjrjr I wrote a reasonable one, which implements plenty of things, and is used by PHP and MongoDB (at least): github.com/derickr/timelib — feel free to reach out via email if you want to chat (address can be cryptically found at derickrethans.nl/who.html)

@derickr
Wow, what a better fedi-encounter than that of the author of a "Guide to Date and Time Programming" book. Nice to meet you!

I will certainly be reading up on PHP's datetime facilities, and thankful for your outreach. I'm guilty of leaving PHP out of my reading list. A quick glance tells me there's quite a similarity to Hare's design.

If you are interested, (the Hare project and) I would love some feedback regarding Hare's (nacent, in-progress and unpolished) datetime library. Perhaps you have some wisdom, some design theory we can learn from.

=> @hare
=> harelang.org/community/
=> docs.harelang.org/datetime
=> git.sr.ht/~torresjrjr/hare/tre

Thanks again. Will use that email.

@torresjrjr @hare I'll give a read. It seems that you've already done some of the TZIF parsing yourself? That was quite a hairy (pun intended) thing to do, especially with the new POSIX strings that they're now using for DST transitions for the current (last) ruleset.

@derickr
Yep. Hare is a system's programming language, so it wouldn't be appropriate to ship our own compiled tzdb package like most languages. We have to parse the tzif files like C.

And yes, the POSIX DST ruleset strings are very annoying! We will likely have to move or copy some code from datetime:: to time::chrono::.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.