Some of Your Dates Already Live After 2038

작성자

카테고리:

← 피드로
DEV Community · Serguey Asael Shinder · 2026-09-29 개발(SW)

At fourteen minutes past three
in the morning, UTC,
on the nineteenth of January 2038,
a counter runs out.

A lot of software keeps time
as the number of seconds
since the first of January 1970.

When that number is stored
in a signed 32 bit integer,
the largest value it can hold
arrives on that January morning.

One second later
it wraps round to a large negative number,
and the date it describes
is in December 1901.

It sounds like a problem
for somebody else,
a decade and a bit from now.

It is already here,
because your data does not live
only in the present.

A thirty year mortgage
taken out this year
ends in 2056.

A long lived certificate.
A warranty.
A lease.
A pension forecast.
A subscription
somebody set to never expire,
which in practice means
a date very far away.

Every one of those
is a moment after 2038
that your system may be trying
to store, compare or sort
today.

The hardware is quieter still.

A meter,
a controller in a building,
a sensor on a pipe,
installed this year
and expected to run for twenty,
may well be running
on that January morning
without ever getting
another firmware update.

The obvious places
have mostly been fixed.
Modern operating systems
and most modern languages
use 64 bits for time now.

The problem lives
in the less obvious places.

A database column
declared as a plain integer
because it held a timestamp,
and timestamps are numbers.
A binary file format
with four bytes reserved for a date.
A network protocol
designed when four bytes felt generous.
A library compiled for a small device.

So go looking.

Search your schemas
for integer columns that hold times.
Read the specifications
of the file formats you write and read.

Then test it.

Save records dated 2040 and 2060,
and check they come back
exactly as they went in.

Run a copy of the system
with its clock set to 2039,
and walk through the main flows.

Use a date in 2045
in every test of anything
that claims to last forever.

A decade sounds like plenty of time.

For a date that is already
sitting in your database,
it is no time at all.

– Serguey Asael Shinder

원문에서 계속 ↗