5 ms·
Instant bookmark for me. I've always loved the idea of measuring time in computers by a single integer like the timestamp does, but it always seems like such a
by hiAndrewQuinn 3y ago
Instant bookmark for me. I've always loved the idea of measuring time in computers by a single integer like the timestamp does, but it always seems like such a pain to work with outside of that.
- anyfoo 3y agoBecause the bases are all wrong. Common number bases are 10, 16, maybe 8 if you live in the 70s, and 2. Except for the utterly unwieldy binary, none of those bases adapt well to the bases used in representing time, which are mostly the (partially related) bases 60, 12, and, annoyingly, thirty-ish. So you always end up doing opaque arithmetic instead of “just looking at the digits” (which you still can do in decimal for century vs years for example, because we defined centuries to be exactly that).
- PrimeMcFly 3y ago> I've always loved the idea of measuring time in computers by a single integer like the timestamp does Why?
- bloopernova 3y agoThis might interest you, if you haven't already seen it: Unix timestamp clock, in hex! https://retr0.id/stuff/2038/ https://retr0.id/stuff/2038/
- 3np 3y agoFWIW these bash shortcuts are handy if you do this a lot: tss() { date -Is -u -d @$1 ; } tsm() { date -Ins -u -d @$( echo "scale=3; $1 / 1000" | bc) | sed -E -e 's/[0-9]{6}\+/\+/' -e 's/,/./' ; } tsn() { date -Ins -u -d @$( echo "scale=9; $1 / 1000000000" | bc) | sed 's/,/./' ; } $ tss 1700000000 2023-11-14T22:13:20+00:00 $ tsm 1700000000000 2023-11-14T22:13:20.000+00:00 $ tsn 1700000000000000000 2023-11-14T22:13:20.000000000+00:00