💾 Archived View for thrig.me › blog › 1901 › 12 › 13 › epoch-fail.gmi captured on 2023-09-28 at 16:36:47. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-04-19)

➡️ Next capture (2023-11-14)

-=-=-=-=-=-=-

Epoch Fail

The container is an integer, and the epoch for this post is -2147483648 or INT_MIN.

    $ grep INT_MIN /usr/include/sys/limits.h
    #define INT_MIN         (-0x7fffffff-1) /* min value for an int */
    $ cfu 'printf("%d\n", INT_MIN)'
    -2147483648

More relevant is that a particular 32-bit integer counter overflows sometime early in 2038, but there's still plenty of time to fix all that code...

    $ cfu 'printf("%d\n", INT_MAX)'
    2147483647
    $ perl -E 'say 2**31'
    2147483648
    $ perl -e 'printf "%d\n", 2**31 -1'
    2147483647
    $ perl -e 'printf "%b\n", 2**31 -1'
    1111111111111111111111111111111
    $ perl -MTime::Piece -E 'say gmtime(2**31 - 1)->datetime'
    2038-01-19T03:14:07

Otherwise, early in 2038 the 32-bit unix epoch will rollover to 1901.

rollover.c

    $ make rollover && ./rollover
    cc -O2 -pipe    -o rollover rollover.c
    2038-01-19 03:14:07
    1901-12-13 20:45:52

Signs and Portents

December the 13th is a Friday in 1901.

More likely, one might see oddities, such as for when folks who had not read the documentation for localtime(3) in sufficient detail ran into the following year 2000 blooper:

    $ perl -E 'say 19 . (localtime)[5]'
    19122

tags #epoch

bphflog links

bphflog index

next: pa se benji be do'e le ze'u purci