DEV Community

Cover image for My terminal now tells me when I'll finish my book (and UTC midnight tried to stop it)
Kamil
Kamil

Posted on Edited on

My terminal now tells me when I'll finish my book (and UTC midnight tried to stop it)

Summer Bug Smash: Smash Stories ๐Ÿ›๐Ÿ›น

My terminal now tells me when I'll finish the book I'm reading.

I spend my days in a terminal and my evenings reading, so I built oku: an open-source terminal app for Hardcover, the book-tracking site.

This week's release adds pace forecasting:

โ†’ "24 pages/day ยท ~4 days left (โ‰ˆ Saturday)"
โ†’ "4 books behind ยท 0.8 books a week gets you to 20"

The arithmetic was the easy part. The interesting part was a time zone bug.

Hardcover stores dates like 2026-10-20, with no time and no zone. Go reads that as midnight UTC, which in New York is 7 p.m. the day before. So for everyone west of London, every book looked a day older than it was, and a reading goal ending on 31 December "expired" at 7 p.m. that evening.

The fix: a bare date means that calendar day wherever you are, so never convert it to local time.

If you store dates without times anywhere, it's worth checking.

I wrote up how the forecast works and how I tracked down the bug.

How the forecast works, and the UTC-midnight bug: [https://kameleon21.github.io/Personal-Website/blog/oku-pace-forecasting/]
The code (MIT): [https://github.com/Kameleon21/oku]

Top comments (0)