Dates and times in the backend series: 1. Epoch, time zones and java.time · 2. Storing them in databases and JSON
Date and time bugs tend to pass on a developer laptop and then fail by seven hours on a UTC server, charge a guest one night short on a DST change day, or show an order created in the year 55705 when a mobile app sends epoch milliseconds. This post (part 1) covers the model and the code: epoch, UTC and time zones, standard formats, choosing java.time types (JDK 21), the JVM’s time zone, and a booking case study. Part 2, Storing dates and times in databases and JSON, covers PostgreSQL timestamptz, MySQL DATETIME/TIMESTAMP, JDBC/Hibernate and Jackson; every Java output shown here is real output on JDK 21.
At a glance:
flowchart TD
Q{What does the value mean?} -->|an instant| I[Instant]
Q -->|calendar date| LD[LocalDate]
Q -->|future appointment| LZ["Local time + ZoneId"]
E["Epoch: ms or seconds?"] --> I
Z["Store IANA zone id, not offset"] --> LZ
LZ -.-> DST["DST: 23- or 25-hour days"]
S["JVM, DB, container: UTC"] --> CL["Inject Clock, explicit ZoneId"]
1. How computers store time
Key idea: time is stored as the seconds (or milliseconds) since 1970-01-01T00:00:00Z. The number is the same everywhere; bugs usually come from mixing up units and from 32-bit types.
1.1 Unix timestamps (epoch)
Key idea: 1695718262 is a single moment for the whole world, even though Hanoi reads 15:51 and London 09:51. Mixing up seconds and milliseconds is a classic bug.
The epoch (the reference point) is 1970-01-01T00:00:00Z. No time zone, no calendar, just a number.
| Unit | Example | Digits (today) | Who uses it |
|---|---|---|---|
| Seconds | 1695718262 |
10 | Unix time_t, JWT (exp, iat), many REST APIs |
| Milliseconds | 1695718262342 |
13 | JavaScript Date.now(), Java System.currentTimeMillis(), Kafka record timestamps |
Real output when you read one as the other:
Instant.ofEpochSecond(1695718262342L); // +55705-03-04T18:39:02Z (ms read as seconds)
Instant.ofEpochMilli(1695718262L); // 1970-01-20T15:01:58.262Z (seconds read as ms)
Why 1970, leap seconds and Y2038
Why 1970? Unix was created in the late sixties and early seventies, and a round date close to that was picked. There’s no deeper reason.
Leap seconds (extra seconds added to UTC to track the Earth’s rotation): Unix time ignores them and treats every day as exactly 86,400 seconds. When one happens, system clocks either repeat a second or smear it (Google and AWS spread it over 24 hours). Java’s Instant also uses a time scale that assumes 86,400 seconds per day.
1.2 Y2038
If you store epoch seconds in a signed 32-bit integer, the largest value is 2,147,483,647, which is 2038-01-19T03:14:07Z. One second later the number overflows to a negative value:
Instant.ofEpochSecond(Integer.MAX_VALUE); // 2038-01-19T03:14:07Z
Instant.ofEpochSecond((int) (Integer.MAX_VALUE + 1L)); // 1901-12-13T20:45:52Z
Java’s Instant uses a long, so it’s unaffected. But Y2038 lives on in:
INTcolumns holding epoch seconds because someone wanted them “compact”;- MySQL’s
TIMESTAMPtype (which stops exactly in 2038, see part 2); - 32-bit firmware, embedded devices and old file formats.
A 15-year loan taken out in 2024 already has a maturity date after 2038.
Incidentally, plenty of material (the course slides included) gets it backwards that MySQL’s DATETIME “depends on the time zone”. It’s TIMESTAMP that is converted using the session time_zone, demonstrated in Evolving a schema: data types.
2. UTC, GMT and time zones
Key idea: UTC is the time standard, and every time zone is an offset from it (Vietnam is UTC+7). Governments set and change the rules, so you rely on the IANA database rather than your memory.
UTC (Coordinated Universal Time) is based on atomic clocks and adjusted with leap seconds. The original slide says “UTC = GMT = offset 0”: the offsets match, but GMT is a time zone (UK civil time in winter), while UTC is a time standard. London is on BST (UTC+1) in summer, so don’t write “GMT” when you mean “UTC”, and don’t use Europe/London when you mean “no offset”.
Time zones keep 7 a.m. in the morning everywhere. The price: one moment has many representations, and the rules keep changing (Mexico dropped daylight saving time at the end of 2022, Kazakhstan moved to a single UTC+5 zone in March 2024). The IANA tz database (tzdata) records all of that history and is updated several times a year.
2.1 An offset is not a zone id
Key idea: an offset tells you the difference at one instant; a zone id tells you the rules at every instant. You can’t derive the rules from an offset.
| Concept | Example | What it tells you |
|---|---|---|
| Offset | +07:00, -08:00, Z |
How far from UTC at one instant |
| Zone id (IANA) | Asia/Ho_Chi_Minh, Europe/Paris |
The rules: which offset applies when, including daylight saving time (DST) and history |
| Abbreviation | ICT, CST, IST |
Ambiguous: is CST US Central, China or Cuba? Never store or parse these |
Paris is +01:00 in winter and +02:00 in summer. Store only +01:00 and you can’t know Paris’s offset six months from now.
Two rare zone id traps: Etc/GMT’s inverted sign and Asia/Ho_Chi_Minh’s history
2.2 DST: a day isn’t always 24 hours long
Key idea: in regions with daylight saving time (DST), each year has one 23-hour day and one 25-hour day. So some local times don’t exist, some happen twice, and “add one day” isn’t “add 24 hours”.
- Gap: clocks jump from 02:00 to 03:00, so 02:30 on 31 March 2024 never happened in Paris.
- Overlap: clocks fall back from 03:00 to 02:00, so 02:30 on 27 October 2024 happened in Paris at
+02:00and again at+01:00.
java.time handles both deterministically (real output):
ZoneId paris = ZoneId.of("Europe/Paris");
ZonedDateTime.of(LocalDateTime.of(2024, 3, 31, 2, 30), paris);
// 2024-03-31T03:30+02:00[Europe/Paris] gap: shifted past the missing hour
ZonedDateTime o = ZonedDateTime.of(LocalDateTime.of(2024, 10, 27, 2, 30), paris);
o.withEarlierOffsetAtOverlap(); // 2024-10-27T02:30+02:00[Europe/Paris]
o.withLaterOffsetAtOverlap(); // 2024-10-27T02:30+01:00[Europe/Paris]
ZonedDateTime before = ZonedDateTime.of(LocalDateTime.of(2024, 3, 30, 9, 0), paris);
before.plusDays(1); // 2024-03-31T09:00+02:00[Europe/Paris]
before.plus(Duration.ofHours(24)); // 2024-03-31T10:00+02:00[Europe/Paris]
Duration.between(before, before.plusDays(1)).toHours(); // 23
Weekly recurring events are where DST bites hardest. “9 a.m. Monday in Berlin” has to stay at 9 local time across the switch, so you store an RRULE, the local time and the zone id rather than instants exactly 7×24 hours apart; the table design is in Data modeling case studies.
3. Formats: ISO 8601, RFC 3339 and friends
Key idea: JSON APIs use RFC 3339 (ISO 8601 with full date, time and offset required), for example 2023-09-25T09:20:52.342Z. Local display formats are for the UI only.
HTTP headers (Date, Expires) use RFC 1123 (Mon, 25 Sep 2023 09:20:52 GMT), and email uses RFC 2822/5322. Never use Date#toString for anything.
The full table of date-time formats and where they’re used
| Standard | Example | Where it’s used |
|---|---|---|
| ISO 8601 | 2023-09-25T16:20:52+07:00, 2023-09-25T09:20:52Z |
The international standard, very broad (week dates, ordinal dates, basic format 20230925T162052) |
| RFC 3339 | 2023-09-25T09:20:52.342Z |
An Internet “profile” of ISO 8601; this is what JSON APIs should use |
| RFC 2822 / 5322 | Mon, 25 Sep 2023 09:16:58 +0000 |
Email headers |
| RFC 1123 (HTTP-date, RFC 9110) | Mon, 25 Sep 2023 09:20:52 GMT |
HTTP Date, Expires, Last-Modified headers |
| Display format for Vietnamese users | 25/09/2023 16:20 |
UI only, never in an API |
java.util.Date#toString |
Tue Sep 26 15:51:02 ICT 2023 |
Nothing: depends on the JVM time zone, ambiguous abbreviations |
2023-09-25T16:20:52+07:00 and 2023-09-25T09:20:52Z are the same moment; Z (Zulu) means +00:00. In Java, equals isn’t isEqual (real output):
OffsetDateTime a = OffsetDateTime.parse("2023-09-25T16:20:52+07:00");
OffsetDateTime b = OffsetDateTime.parse("2023-09-25T09:20:52Z");
a.isEqual(b); // true (same moment)
a.equals(b); // false (different offsets)
Instant.parse("2023-09-25T16:20:52+07:00"); // 2023-09-25T09:20:52Z (JDK 12+ accepts offsets)
LocalDateTime.parse("2023-09-25T09:20:52Z"); // DateTimeParseException: unparsed text found at index 19
A formatting trap: in DateTimeFormatter, YYYY is the week-based year (the year of the ISO week), not the year. Formatting LocalDate.of(2024, 12, 30) with "YYYY-MM-dd" gives 2025-12-30. Use yyyy (or uuuu) and dd (DD is the day of the year); better still, use built-in formatters such as DateTimeFormatter.ISO_OFFSET_DATE_TIME.
4. Choosing the right java.time type
Key idea: choose the type by what the data means: a moment, a calendar date, or a wall-clock time in a region. New code uses java.time (JSR-310, since Java 8), not Date/Calendar.
The legacy API (java.util.Date, Calendar, SimpleDateFormat) is mutable, SimpleDateFormat isn’t thread-safe, months start at 0, and Date is really an instant whose toString prints in the JVM’s time zone.
| Type | Meaning | Example data |
|---|---|---|
Instant |
A point on the global timeline (UTC) | created_at, payment time, logs, events |
OffsetDateTime |
An instant plus the offset at that moment | Values received from an API with an offset; writing timestamptz via JDBC |
ZonedDateTime |
An instant plus a zone id (with DST rules) | Calendar maths in a region: “9 a.m. tomorrow in Paris” |
LocalDateTime |
A wall-clock date and time that belongs to no region | A future appointment (alongside a zone id column), scheduled opening times |
LocalDate |
A calendar date | Birth date, check-in date, pay period, public holiday |
LocalTime |
A time of day | Opening time 08:00 |
Duration / Period |
Machine-measured length / calendar-based amount | A 30-second timeout / a one-month extension |
ZoneId |
Time zone rules | The user’s or the property’s time zone |
A question that helps: “If the user flies to another country, should this value change?” A payment time doesn’t (Instant). A birth date doesn’t either, but it isn’t a moment (LocalDate). “Alarm at 7 a.m.” travels with the person (LocalTime plus the user’s current zone).
4.1 Zone ids: use ZoneId.of, not TimeZone.getTimeZone
Key idea: ZoneId.of fails fast on a bad id; TimeZone.getTimeZone silently returns GMT.
4.2 Inject a Clock instead of calling now() everywhere
Key idea: argument-less now() is a hidden input (the JVM’s clock and time zone). Inject a Clock so the code doesn’t depend on the environment and tests can hit every edge case.
@Configuration
class TimeConfig {
@Bean Clock clock() { return Clock.systemUTC(); }
}
@Service
@RequiredArgsConstructor
class InvoiceService {
private final Clock clock;
Instant issuedAt() { return clock.instant(); }
}
// In tests: frozen time, so every edge case is reproducible
Clock fixed = Clock.fixed(Instant.parse("2024-06-09T17:30:00Z"), ZoneOffset.UTC);
5. The JVM, the OS and the container
Key idea: the JVM has its own default time zone and its own copy of tzdata, which can differ from the OS and the database. The safe path: everything runs in UTC, and calendar maths passes an explicit ZoneId.
The JVM picks its default zone (ZoneId.systemDefault()) at startup from user.timezone, then the TZ variable, then /etc/localtime. So it can differ from the OS time zone you see when you SSH in, and from the database’s.
Things that depend on the JVM default: LocalDate.now(), Date#toString, a SimpleDateFormat without a zone, Jackson with java.util.Date, and PgJDBC (the driver sends the JVM zone as the PostgreSQL session TimeZone; part 2 explains why that matters).
The JDK ships its own tzdata: where to update time zone rules
The JDK ships its own copy of tzdata (the tzdb.dat file inside the JDK) and doesn’t read the OS’s. When a country changes its rules, you need a JDK update (patch releases usually include new tzdata) or Oracle’s TZUpdater tool; updating the OS isn’t enough.
PostgreSQL may use the OS tzdata or its bundled copy, depending on how it was built. Three places (JVM, OS, database) can be running three different versions of the rules.
With Spring, @Scheduled(cron = "0 0 2 * * *", zone = "Asia/Ho_Chi_Minh") runs a job on Vietnam time even if the JVM is in UTC (see Cron jobs). In zones with DST, avoid scheduling jobs between 01:00 and 03:00, since those times may not exist or may happen twice.
6. Case study: “today” and the number of nights in a booking
Key idea: the course’s homestay booking sample uses LocalDate.now() to reject check-ins in the past. That only works while the server, the guest and the homestay share a time zone; with a UTC server it breaks.
6.1 Whose “today”?
Key idea: a booking’s “today” is the date in the homestay’s time zone, not the server’s.
// Bug: "today" is the JVM's date, not the homestay's
static boolean isPastBuggy(LocalDate checkin, Clock serverClock) {
return checkin.isBefore(LocalDate.now(serverClock));
}
UTC server, real results:
| Scenario | UTC time | isPastBuggy |
Should be |
|---|---|---|---|
| Da Lat homestay. 00:30 on 10 June Vietnam time, guest books check-in on 9 June (yesterday) | 2024-06-09T17:30Z | false (allowed) |
Past, must reject |
| Los Angeles homestay. 17:30 on 9 June LA time, guest books check-in on 9 June (today) | 2024-06-10T00:30Z | true (rejected) |
Today, must allow |
The fix: each homestay stores a ZoneId (a time_zone text column, e.g. Asia/Ho_Chi_Minh). For the two scenarios above, isPast returns true and false respectively, with no change to the server’s time zone.
record Homestay(String name, ZoneId zone) {}
static boolean isPast(LocalDate checkin, Homestay h, Clock clock) {
return checkin.isBefore(LocalDate.now(clock.withZone(h.zone())));
}
6.2 The number of nights
Key idea: nights are a calendar concept, so compute them with ChronoUnit.DAYS.between on LocalDate, not from a Duration between two moments.
static long nights(LocalDate checkin, LocalDate checkout) {
return ChronoUnit.DAYS.between(checkin, checkout);
}
A common wrong variant computes from moments (check-in 14:00, check-out 12:00) and calls Duration#toDays, so the guest gets a night for free.
Why nightsBuggy loses nights, and the half-open convention
static long nightsBuggy(LocalDate checkin, LocalDate checkout, ZoneId zone) {
ZonedDateTime in = checkin.atTime(14, 0).atZone(zone);
ZonedDateTime out = checkout.atTime(12, 0).atZone(zone);
return Duration.between(in, out).toDays();
}
Real output in Los Angeles: 9 → 12 March 2024 gives nights = 3 but nightsBuggy = 2; 9 → 10 June (one night) gives nightsBuggy = 0. A 14:00 → 12:00 span is always two hours short of whole days, and the DST change day (10 March 2024 in LA) has only 23 hours. toDays() truncates.
One more detail from the sample: the availability query uses date BETWEEN checkin AND checkout - 1. The half-open convention [checkin, checkout) (the check-out night isn’t counted) has to be consistent across the query, the nights function and pricing; someone passing checkout instead of checkout - 1 books an extra night. Make the convention explicit in names or Javadoc, and use checkin.datesUntil(checkout) (JDK 9+) when you need to list each night.
Exercises
Exercise 1: Convert Hanoi time to Tokyo, Paris and California
Task (paraphrased): Given the moment 2023-09-26T07:15:52+07:00 in Hanoi, write that moment in Tokyo, Paris and California as ISO 8601 with offsets.
Solution to Exercise 1: zone ids instead of fixed offsets
The original slide used fixed offsets (Tokyo +09, Paris +01, California −08) and got Paris 01:15:52+01:00 and California 2023-09-25T16:15:52-08:00. At the end of September, Paris and California are on summer time, so both results are an hour off. With zone ids:
Instant instant = OffsetDateTime.parse("2023-09-26T07:15:52+07:00").toInstant();
for (String zone : List.of("Asia/Tokyo", "Europe/Paris", "America/Los_Angeles")) {
System.out.println(zone + " -> " + instant.atZone(ZoneId.of(zone)).toOffsetDateTime());
}
Real output:
Asia/Tokyo -> 2023-09-26T09:15:52+09:00
Europe/Paris -> 2023-09-26T02:15:52+02:00
America/Los_Angeles -> 2023-09-25T17:15:52-07:00
California is still on the previous day. The same conversion in January does give +01:00 and -08:00. That’s exactly why you must not hard-code offsets: an offset is the result of applying the rules at a moment, not a fixed property of a city.
Exercise 2: Check-in date and nights, with tests
Task (paraphrased): Write a function that checks a check-in date isn’t in the past according to the homestay’s time zone, and one that computes the number of nights, with tests for the edge cases.
Solution to Exercise 2: JUnit tests with Clock.fixed
Use isPast and nights from section 6. Tests (JUnit 5, condensed):
@Test
void vietnamJustAfterMidnight_yesterdayIsPast() {
Clock clock = Clock.fixed(Instant.parse("2024-06-09T17:30:00Z"), ZoneOffset.UTC); // 00:30 on 10 June in Vietnam
Homestay dalat = new Homestay("Da Lat", ZoneId.of("Asia/Ho_Chi_Minh"));
assertTrue(isPast(LocalDate.of(2024, 6, 9), dalat, clock));
}
@Test
void losAngelesEvening_todayIsNotPast() {
Clock clock = Clock.fixed(Instant.parse("2024-06-10T00:30:00Z"), ZoneOffset.UTC); // 17:30 on 9 June in LA
Homestay la = new Homestay("Venice Beach", ZoneId.of("America/Los_Angeles"));
assertFalse(isPast(LocalDate.of(2024, 6, 9), la, clock));
}
@Test
void nightsAcrossDstChange() {
assertEquals(3, nights(LocalDate.of(2024, 3, 9), LocalDate.of(2024, 3, 12)));
}
These values were checked with a program run on JDK 21 (same logic, without JUnit).
Exercise 3: Normalise epoch input
Task (paraphrased): A legacy API takes a numeric timestamp; the web client sends milliseconds and the IoT client sends seconds. Write a function that converts it to an Instant.
Solution to Exercise 3: guess the unit from the magnitude
static Instant fromEpochGuess(long value) {
// 10^11 seconds is the year 5138; 10^11 ms is 1973. Below the threshold it's seconds.
return Math.abs(value) < 100_000_000_000L ? Instant.ofEpochSecond(value) : Instant.ofEpochMilli(value);
}
// fromEpochGuess(1695718262L) -> 2023-09-26T08:51:02Z
// fromEpochGuess(1695718262342L) -> 2023-09-26T08:51:02.342Z
This is a stopgap. A senior engineer would also version the API to accept RFC 3339 strings or a field with the unit in its name (occurredAtMs), log a warning whenever a guess is needed, and reject values outside a plausible range (say, before 2000 or later than now plus one day).
Remember
- Explain why an epoch value doesn’t depend on the time zone, and spot seconds-vs-milliseconds mix-ups from the magnitude.
- Tell offsets, zone ids and abbreviations apart; know why future appointments need a stored zone id.
- Know when to use
plusDays(1)/Periodand whenDuration, and why they differ on a DST change day. - Pick the right
java.timetype for a moment, a birth date and an appointment; know how injecting aClockmakes code testable. - Explain “whose today?” in the booking case and why nights are computed on
LocalDate.
Interview questions
Junior
What is a Unix timestamp? Does it depend on the time zone?
It’s the number of seconds (or milliseconds) since 1970-01-01T00:00:00Z, and it doesn’t depend on the time zone.
The same number is the same moment everywhere; the time zone only matters when you display it as a local date and time. Always be explicit about the unit, because JavaScript uses milliseconds while JWT and Unix use seconds.
Are 2023-09-25T16:20:52+07:00 and 2023-09-25T09:20:52Z equal?
They’re the same moment, because Z means an offset of +00:00.
In Java, OffsetDateTime#isEqual returns true but equals returns false because the offsets differ. To compare moments, use isEqual, compareTo on Instant, or convert both to Instant first.
When do you use LocalDate and when Instant?
Instant is for a point on the global timeline; LocalDate is for a calendar date that isn’t tied to a specific moment.
Instant: creation time, payment time, events. LocalDate: birth date, check-in date, public holiday. A quick test: should the value change if the time zone changes? Your birthday doesn’t change when you fly to the US, but it isn’t a moment either.
Mid
How does an offset differ from a zone id? Why store the zone id?
An offset is the difference from UTC at one moment; a zone id is the rule set for every moment. Store the zone id when you need future calendar calculations.
You can’t derive the rules from an offset (+02:00), so you can’t compute times at other moments (a weekly event across a DST change, for example). A zone id (Europe/Paris) says which offset applies when, including DST and historical changes. An offset is only enough to pin down a moment you already know.
How does plusDays(1) differ from plus(Duration.ofHours(24))?
On a ZonedDateTime, plusDays(1) keeps the local clock time, while adding 24 hours means exactly 86,400 seconds pass.
On a DST change day they differ by an hour: in Paris at 09:00 on 30 March 2024, plusDays(1) gives 09:00 the next day and adding 24 hours gives 10:00. Use Period/plusDays for calendar things (appointments) and Duration for durations (TTLs, timeouts).
Why can the JVM’s time zone differ from the server’s?
Because the JVM picks its own default zone at startup and uses the tzdata bundled inside the JDK.
It reads -Duser.timezone, the TZ variable, then /etc/localtime; a container can have a different TZ from its host. So date in the shell and ZoneId.systemDefault() can disagree, and the JVM’s rules can be older than the OS’s. The safe approach: pin the JVM and container to UTC, pass a ZoneId explicitly for all calendar calculations, and keep the JDK updated for fresh tzdata.
How do you test code that depends on the current time?
Inject a java.time.Clock and use Clock.fixed in tests.
In production use a Clock.systemUTC() bean and call Instant.now(clock) or LocalDate.now(clock.withZone(zone)). In tests pick the edge cases: just after local midnight, DST change days, 31 December, 29 February. Avoid argument-less now() and Thread.sleep in tests.
Senior
A booking system computes “today” wrongly for guests abroad. How do you analyse and fix it?
“Today” belongs to the asset’s (the homestay’s) time zone, not the server’s or the guest’s; the bug usually comes from LocalDate.now() using the JVM zone.
- Add a zone id column to the homestay, inject a
Clock, computeLocalDate.now(clock.withZone(homestay.zone())). - Compute nights with
ChronoUnit.DAYS.betweenonLocalDate, never from aDuration. - Test at 00:30 and 23:30 local time and on DST change days.
- Hunt for the same pattern elsewhere (daily reports, period closing, date-based promotions) and add a static analysis rule that bans argument-less
now().
What happens to your system when time zone rules change?
Past data stored as instants stays correct; future data stored as instants computed with the old rules displays at the wrong local time.
For example, a 9:00 appointment becomes 8:00 after the change. That’s why future appointments should be stored as local time plus zone id and converted to an instant only when needed. Also, tzdata must be updated everywhere: the JDK (a patch release or TZUpdater), the database, the OS, frontend libraries; three components on three versions of the rules is a hard-to-find source of drift.
What time conventions would you set for a multi-service system?
Store and transmit moments in UTC, use RFC 3339 with an offset in APIs, run everything in UTC, and pass an explicit ZoneId to calendar calculations.
- Store
Instant/timestamptz; never use zone abbreviations. - Every service, database session and container runs in UTC.
- Pure dates (birth dates, check-in dates) are
LocalDate/date; future appointments are local time plus zone id. - Inject a
Clockfor testing. - Write it down in an ADR and enforce it through code review and static rules.
Useful phrases for interviews
- “That field is a point in time, so I’d model it as an
Instantand store it in UTC.” - “A birth date isn’t a moment; it’s a calendar date, so it’s a
LocalDate.” - “An offset only tells you the difference at one instant; the zone id carries the rules, including DST.”
- “We never hard-code plus one for Paris, because it’s plus two for half the year.”
- “Whose ‘today’ is it? For bookings, it’s the property’s time zone, not the server’s.”
- “We inject a
Clock, so tests can freeze time at midnight or on a DST change day.” - “Everything runs in UTC, and we convert to local time only at the edges.”
- “Is that value in seconds or milliseconds? Let’s put the unit in the field name.”
- “Adding one day and adding 24 hours aren’t the same thing on a daylight-saving transition.”
Notes based on the Advanced Backend course (Ronin Engineer), rewritten in my own words.