Ridley @ WATCH LYCORECO
(replying to Kanbaru 🌟 (one hikari of too many))
@hikari does "I've researched how libraries do this before and I'm pretty sure I could reimplement that from memory" count
Kanbaru 🌟 (one hikari of too many)
(replying to Ridley @ WATCH LYCORECO)
@rcombs perhaps! I'm curious what strategy they use, do they also do (timestamp % 400yearperiod) but then perhaps divide by 365 and do some sort of trick to turn it into a correct integer?
Ridley @ WATCH LYCORECO
(replying to Kanbaru 🌟 (one hikari of too many))
@hikari musl approach: simple, all fairly intelligible numbers; lots of modulo; some explicit branching for edges: https://github.com/bminor/musl/blob/f5f55d6589940fd2c2188d76686efe3a530e64e0/src/time/__secs_to_tm.c#L35
the libcxx approach: just do a bunch of divides by constants lol https://github.com/llvm/llvm-project/blob/51eeea67c67cb3e622730ee1fa8c9b939268429b/libcxx/include/__chrono/year_month_day.h#L75
Kanbaru 🌟 (one hikari of too many)
(replying to Ridley @ WATCH LYCORECO)
@rcombs heh, thanks. both pretty elegant in their own ways!