JavaScript / Intermediate: modules and asynchronous contracts / Lesson 14
Dates, instants, and calendar boundaries
Distinguish an instant from a date on a calendar and validate date-only input without letting the host time zone change its meaning.
On this page
Lesson goals
- Distinguish instants, calendar dates, and formatted display.
- Validate a date-only input against its stated format.
- Test time-zone and invalid-date boundaries.
- Distinguish date-only values from instants and validate calendar boundaries.
- Normalize explicit instants and render them in an intentional named zone.
Choose the meaning before the type
An instant is a point on the global timeline; a calendar date such as a birthday identifies a day without a time or time zone. These are different domain values even if both are written with digits and hyphens. A meeting also needs a zone or offset and an agreed policy for ambiguous local times. Write the contract first: store a timestamp for an event that has happened, but preserve a date-only value for a birthday rather than inventing a local midnight.
Represent an instant explicitly
A Date represents a time value, and an ISO string ending in Z states a UTC instant. getTime returns a numeric timestamp or NaN for an invalid Date; toISOString produces a UTC representation for a valid one. The example uses a complete timestamp with an explicit offset, so the instant does not depend on the machine’s local zone. Displaying that instant in a user’s local zone is a separate formatting decision, not a change to the instant itself.
const instant = new Date("2025-01-15T12:00:00Z");
console.log(instant.toISOString());
console.log(Number.isNaN(instant.getTime()));
The Z suffix supplies UTC; the validity check inspects the resulting time value.
Validate a calendar date
A date-only field needs both a shape check and a real calendar-day check. The following bounded example accepts exactly four digits for the year and two each for month and day, then checks that the UTC round trip preserves the original date. Returning the original string preserves date-only semantics. It does not support every possible historical calendar convention; choose an explicit supported year range for a real product and test its boundaries.
function parseDateOnly(text) {
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text);
if (!match) return null;
const [, year, month, day] = match;
const date = new Date(`${year}-${month}-${day}T00:00:00Z`);
return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === text
? text : null;
}
console.log(parseDateOnly("2025-02-28"));
console.log(parseDateOnly("2025-02-30"));
The format check and UTC round trip reject invalid dates while the result remains a date-only string.
Keep display and storage separate
A user may see the same instant as different local dates in different zones. That is expected formatting, not proof that the stored instant changed. Conversely, converting a date-only birthday to midnight UTC and formatting it locally can show the previous day in a negative offset. Keep the original date-only representation until a feature explicitly supplies a time and zone. For scheduled local events, document how daylight-saving gaps and repeated times are resolved by the chosen time-zone library or service.
Test the contract, not a machine default
Test ordinary dates, leap days, invalid days, malformed text, and the product’s minimum and maximum supported years. For instant displays, run the same fixture under at least two configured time zones and assert the intended local presentation as well as the unchanged instant. Do not rely on an unspecified date string format or the developer machine’s local zone. Keep tests deterministic by fixing input timestamps and supplying the zone used for display.
Separate an instant from a calendar date
An instant identifies a point on the global timeline. A calendar date such as a birthday identifies a day in a calendar, without specifying a time or time zone. Those are different domain values even when both are written with digits and hyphens. A birthday should remain a validated date-only value unless the application actually needs a separate event time and zone. Inventing midnight UTC for a birthday can make a display in another zone show the previous day.
A JavaScript Date represents a time value, not a date-only birthday. Before choosing a representation, ask whether the data means an instant, a date, a local time, or a scheduled local date and time in a named zone. Document the calendar and the interpretation at the boundary. A timestamp with an explicit Z or offset can identify an instant; a date-only string should not be silently treated as a user's local birthday instant.
Normalize explicit instants
For an instant, accept a documented timestamp format with an explicit offset and validate the parsed result. The Z suffix indicates UTC; an offset such as +02:00 describes how the supplied clock time relates to UTC. Different textual timestamps can represent the same instant. Converting a valid Date to toISOString produces a UTC representation ending in Z, which is useful for storing and comparing instants. Check Number.isNaN(date.getTime()) before formatting, because an invalid Date cannot be converted to an ISO string successfully.
Do not assume every date-like string has portable or intended parsing behavior. Define the accepted input format rather than relying on implementation-specific parsing of informal text. A numeric timestamp is measured in milliseconds since the epoch in JavaScript, not seconds. When crossing an API boundary, document units explicitly. The examples use explicit ISO timestamps and UTC operations so their results do not depend on the machine's local time zone.
Validate the entire calendar value
A date-only parser should validate both its representation and the calendar day. A pattern such as four digits, a hyphen, two digits, a hyphen, and two digits establishes shape but does not prove that February has the requested day. Check month bounds, month length, and leap-year rules. A Gregorian leap year is divisible by four, except a year divisible by 100 must also be divisible by 400. Thus 2024-02-29 exists, while 2025-02-29 and 1900-02-29 do not; 2000-02-29 does.
JavaScript Date construction can normalize out-of-range components into a different date, so a plausible resulting Date alone is not evidence that the original calendar input was valid. If using a UTC round trip for an explicitly supported year range, compare the resulting UTC year, month, and day to the supplied components. Take care with Date.UTC's special treatment of years 0 through 99; either handle that case deliberately or restrict and document the supported range. Reject invalid dates rather than silently rolling them into another month.
Render an instant in the intended zone
The same instant can fall on different local calendar dates in different time zones. For example, shortly after midnight UTC may still be the previous evening in a zone west of UTC. That difference is expected when displaying an instant, but it is not a reason to change a stored birthday. Use Intl.DateTimeFormat with an explicit locale and timeZone when formatting an instant for a particular user or business context. Do not depend on the server's default local zone for a domain decision.
Named time zones contain historical and daylight-saving rules that cannot be represented reliably by one fixed offset for every date. A local scheduled time may be ambiguous or nonexistent around a clock transition, so a scheduling product needs an explicit zone and a documented policy for such cases. The Date object alone does not encode all scheduling intent. Tests should specify the instant, zone, calendar, and expected components, and should account for the time-zone data available in the target runtime.
Test meaning and boundaries independently
Construct separate tests for date-only values and instants. For a birthday, assert that the validated year, month, and day remain the same fields through storage and retrieval, without passing them through a zone conversion. For an instant, assert the expected UTC timestamp and then test its display in explicitly named zones. Include an instant near midnight, a leap day, invalid month lengths, and an invalid timestamp. Compare stable components or machine-readable output rather than a locale-dependent punctuation pattern.
Use synthetic dates and set all assumptions in the test. Test the exact accepted syntax, valid and invalid leap years, and the selected supported year range. Verify the same instant expressed with two offsets compares equal, while two different instants remain distinct. A successful browser or Node test demonstrates behavior in that runtime and its time-zone data; it does not prove every deployment has identical internationalization data. Keep storage values separate from localized display strings.
20 worked examples
1. UTC instant
Problem: Normalize an explicit UTC timestamp to its ISO representation.
- The Z suffix specifies a UTC instant at midnight.
- toISOString renders the same instant in UTC with milliseconds and a Z suffix.
const d = new Date("2025-01-01T00:00:00Z"); console.log(d.toISOString());
2025-01-01T00:00:00.000Z
Why this result follows: toISOString renders the same instant in UTC with milliseconds and a Z suffix.
2. Offset normalization
Problem: Convert a timestamp with a positive offset into UTC.
- The supplied local clock is two hours ahead of UTC.
- Subtracting the two-hour offset places the very same timeline instant at midnight in UTC.
console.log(new Date("2025-01-01T02:00:00+02:00").toISOString());
2025-01-01T00:00:00.000Z
Why this result follows: Subtracting the two-hour offset places the very same timeline instant at midnight in UTC.
3. Equivalent instants
Problem: Compare two offset representations of the same timeline instant.
- The second clock time is two hours ahead of UTC.
- Both timestamps resolve to the same millisecond time value despite different text.
const a = new Date("2025-01-01T00:00:00Z"); const b = new Date("2025-01-01T02:00:00+02:00"); console.log(a.getTime() === b.getTime());
true
Why this result follows: Both timestamps resolve to the same millisecond time value despite different text.
4. Different instants
Problem: Compare two timestamps separated by one second on the timeline.
- The timestamps differ by one second.
- JavaScript Date time values use milliseconds, so the difference is one thousand.
const a = new Date("2025-01-01T00:00:00Z"); const b = new Date("2025-01-01T00:00:01Z"); console.log(b.getTime() - a.getTime());
1000
Why this result follows: JavaScript Date time values use milliseconds, so the difference is one thousand.
5. Epoch milliseconds
Problem: Construct a Date from a numeric millisecond timestamp at the epoch.
- Numeric zero denotes zero milliseconds from the JavaScript epoch.
- The resulting UTC instant is the beginning of January first 1970 at midnight precisely.
console.log(new Date(0).toISOString());
1970-01-01T00:00:00.000Z
Why this result follows: The resulting UTC instant is the beginning of January first 1970 at midnight precisely.
6. One second after epoch
Problem: Convert one thousand epoch milliseconds into an explicit UTC instant.
- One thousand milliseconds is one second after the epoch.
- The ISO representation advances the seconds field to one for this epoch-millisecond input.
console.log(new Date(1000).toISOString());
1970-01-01T00:00:01.000Z
Why this result follows: The ISO representation advances the seconds field to one for this epoch-millisecond input.
7. Detect invalid instant
Problem: Check the time value before formatting an invalid Date object.
- The invalid input produces a Date with a NaN time value.
- Number.isNaN identifies the invalid time value before attempting an ISO formatting operation on the Date.
const d = new Date("not-a-date"); console.log(Number.isNaN(d.getTime()));
true
Why this result follows: Number.isNaN identifies the invalid time value before attempting an ISO formatting operation on the Date.
8. Invalid ISO formatting
Problem: Handle the error from converting an invalid Date to ISO text.
- The Date does not have a valid time value.
- toISOString throws a RangeError instead of returning a valid timestamp for that invalid date.
try { new Date("bad").toISOString(); } catch (e) { console.log(e instanceof RangeError); }
true
Why this result follows: toISOString throws a RangeError instead of returning a valid timestamp for that invalid date.
9. Leap year 2024
Problem: Check whether 2024 is a Gregorian leap year using its divisibility rules.
- The year is divisible by four and is not divisible by one hundred.
- It satisfies the Gregorian leap-year rule, allowing February 29 in that year.
const y = 2024; console.log(y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0));
true
Why this result follows: It satisfies the Gregorian leap-year rule, allowing February 29 in that year.
10. Ordinary year 2025
Problem: Check whether February has a leap day in the year 2025.
- The year is not divisible by four.
- The leap-year condition fails, so February has only 28 days in 2025.
const y = 2025; console.log(y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0));
false
Why this result follows: The leap-year condition fails, so February has only 28 days in 2025.
11. Century exception
Problem: Check the leap-year rule for the century year 1900.
- The year is divisible by one hundred but not by four hundred.
- The century exception makes 1900 a common year despite divisibility by four.
const y = 1900; console.log(y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0));
false
Why this result follows: The century exception makes 1900 a common year despite divisibility by four.
12. Four-hundred-year exception
Problem: Check the leap-year rule for the century year 2000.
- The year is divisible by four hundred as well as one hundred.
- The four-hundred-year exception makes the century year 2000 a Gregorian leap year.
const y = 2000; console.log(y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0));
true
Why this result follows: The four-hundred-year exception makes the century year 2000 a Gregorian leap year.
13. Valid leap-day round trip
Problem: Check UTC components for the valid calendar date 2024-02-29.
- The zero-based month index one denotes February.
- The UTC components round trip to the supplied year, month, and valid day.
const d = new Date(Date.UTC(2024, 1, 29)); console.log(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
2024 2 29
Why this result follows: The UTC components round trip to the supplied year, month, and valid day.
14. Detect normalization
Problem: Observe how an invalid February day can normalize into March.
- February 2025 has only 28 days, so the component overflows.
- The resulting March first does not match the requested date and must not be silently accepted.
const d = new Date(Date.UTC(2025, 1, 29)); console.log(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
2025 3 1
Why this result follows: The resulting March first does not match the requested date and must not be silently accepted.
15. Reject month thirteen
Problem: Detect normalization of an out-of-range calendar month using UTC components.
- Month index twelve is beyond December in the zero-based constructor.
- Construction rolls into January 2026, so a date-only validator must reject the original month thirteen.
const d = new Date(Date.UTC(2025, 12, 1)); console.log(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
2026 1 1
Why this result follows: Construction rolls into January 2026, so a date-only validator must reject the original month thirteen.
16. Date-only string remains text
Problem: Preserve a validated birthday as a date-only string without a zone conversion.
- The value is stored as the supplied date-only representation.
- No instant or midnight offset is invented, so the calendar fields remain unchanged.
const birthday = "2025-02-28"; console.log(birthday);
2025-02-28
Why this result follows: No instant or midnight offset is invented, so the calendar fields remain unchanged.
17. UTC calendar components
Problem: Read explicit UTC date components from a known timestamp.
- The UTC timestamp lies on the first day of January.
- UTC getters avoid dependence on the machine local time zone for these components.
const d = new Date("2025-01-01T00:30:00Z"); console.log(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
2025 1 1
Why this result follows: UTC getters avoid dependence on the machine local time zone for these components.
18. West-zone previous date
Problem: Display the date components of an instant in America/New_York.
- The instant is still the prior evening in New York on this date.
- The explicit named zone yields December 31 while preserving the original UTC instant.
const f = new Intl.DateTimeFormat("en-CA", { timeZone: "America/New_York", year: "numeric", month: "2-digit", day: "2-digit" }); const parts = Object.fromEntries(f.formatToParts(new Date("2025-01-01T00:30:00Z")).map(p => [p.type, p.value])); console.log(parts.year + "-" + parts.month + "-" + parts.day);
2024-12-31
Why this result follows: The explicit named zone yields December 31 while preserving the original UTC instant.
19. East-zone same date
Problem: Display the same instant as date components in Asia/Tokyo.
- The same instant falls on January first in Tokyo.
- A named display zone changes local calendar components without changing the stored instant.
const f = new Intl.DateTimeFormat("en-CA", { timeZone: "Asia/Tokyo", year: "numeric", month: "2-digit", day: "2-digit" }); const parts = Object.fromEntries(f.formatToParts(new Date("2025-01-01T00:30:00Z")).map(p => [p.type, p.value])); console.log(parts.year + "-" + parts.month + "-" + parts.day);
2025-01-01
Why this result follows: A named display zone changes local calendar components without changing the stored instant.
20. Date shape alone
Problem: Show that a date-shaped string can contain an impossible calendar day.
- The pattern checks only the positions and number of digits.
- The shape passes even though February 29 is invalid in the non-leap year 2025.
const s = "2025-02-29"; console.log(/^\d{4}-\d{2}-\d{2}$/.test(s));
true
Why this result follows: The shape passes even though February 29 is invalid in the non-leap year 2025.
Common errors and fixes
A birthday shifts by one day
- Why it happens
- A date-only value was treated as a UTC instant and rendered in a local zone.
- How to fix it
- Preserve the date-only value and format it as a calendar date.
- Prevent it next time
- Document whether every field is a date, instant, or local appointment.
An invalid date is accepted after normalization
- Why it happens
- A parser can normalize an out-of-range day rather than enforcing the input contract.
- How to fix it
- Check the input shape and compare the round-trip date with the original.
- Prevent it next time
- Test invalid month and day boundaries alongside leap days.
A test passes only on one machine
- Why it happens
- The test implicitly uses the machine time zone or current clock.
- How to fix it
- Fix the input instant and explicitly configure the intended display zone.
- Prevent it next time
- Run representative zone cases in automated tests.
20 practice exercises
1. Is a birthday an instant? What should be stored?
Show hint
Identify whether a birthday specifies a clock time and zone.
Show worked solution
A birthday identifies a calendar date, not a unique instant. Preserve a validated date-only value such as 2025-02-28 and avoid inventing midnight in a zone. The presentation layer may localize its display while retaining that underlying meaning.
A birthday is a calendar date, not a unique instant. Store a validated date-only representation such as 2025-02-28 and do not invent midnight in a zone. Localize its presentation while preserving the same underlying calendar fields.
Check your solution
- The date-only fields remain unchanged.
- No time zone is invented for the birthday.
2. Why can two users see different dates for one instant?
Show hint
Separate the stored instant from each zone-specific display.
Show worked solution
The instant is shared, but local offsets can place it on different calendar days. Verify that the same UTC instant is stored and that each display uses the intended user zone. This differs from a birthday shifting, because a birthday should not have been converted into an instant.
A single UTC instant can fall on different local calendar dates because zones have different offsets and rules. Verify the same instant is stored and each display uses the intended zone. A birthday is different because its date-only meaning should not be shifted through an invented instant.
Check your solution
- The UTC instant is identical for both users.
- Each display uses the intended zone.
3. Explain whether a birthday is a date-only value or a unique timeline instant.
Show hint
A birthday does not specify a clock time and zone.
Show worked solution
A birthday is a calendar date, not a unique instant. Store validated year, month, and day or a documented date-only representation such as 2025-02-28. Do not invent UTC midnight merely to store it; localize presentation without changing the underlying date.
Check your solution
- The stored value preserves calendar fields
- No time zone is invented
4. Normalize 2025-01-01T03:00:00+03:00 to an explicit UTC timestamp. Explain the boundary and expected result.
Show hint
Subtract the positive offset from the supplied clock time.
Show worked solution
The instant is 2025-01-01T00:00:00.000Z. The supplied clock is three hours ahead of UTC, so subtracting the offset reaches midnight UTC. Compare the parsed millisecond values to verify both strings identify the same instant.
Check your solution
- The UTC time is midnight
- Both representations identify the same instant
5. Compare 2025-01-01T00:00:00Z and 2025-01-01T01:00:00+01:00 as instants. Explain the boundary and expected result.
Show hint
Convert the offset representation to UTC.
Show worked solution
They represent the same instant: subtracting the one-hour offset from 01:00 yields 00:00 UTC. Compare their getTime values rather than the original text. Different strings can encode the same point on the timeline.
Check your solution
- The UTC instants are equal
- Their original strings differ
6. Explain the difference between numeric timestamp 1000 and one thousand seconds. Explain the boundary and expected result.
Show hint
JavaScript Date numeric time values use milliseconds.
Show worked solution
new Date(1000) represents one second after the epoch, not one thousand seconds. A seconds-based API value would need an explicit unit conversion before constructing a Date. Document units at the boundary and test a known epoch example.
Check your solution
- 1000 milliseconds equals one second
- API units are explicitly documented
7. Check whether an invalid Date may be safely passed to toISOString. Explain the boundary and expected result.
Show hint
Inspect getTime before formatting.
Show worked solution
Check Number.isNaN(date.getTime()) and reject an invalid time value before formatting. toISOString throws RangeError for an invalid Date rather than returning a usable timestamp. Test both a valid explicit timestamp and malformed input at the boundary.
Check your solution
- Invalid time is detected before formatting
- A valid timestamp formats successfully
8. Determine whether 2024-02-29 and 2025-02-29 are valid Gregorian dates. Explain the boundary and expected result.
Show hint
Apply leap-year rules after checking the date shape.
Show worked solution
2024-02-29 is valid because 2024 is a leap year. 2025-02-29 is invalid because February 2025 has 28 days. A date-shaped regular expression alone accepts both, so validate the calendar day independently.
Check your solution
- 2024 leap day is valid
- 2025 leap day is rejected
9. Compare leap-year validity for the century years 1900 and 2000. Explain the boundary and expected result.
Show hint
A century must be divisible by 400 to be a leap year.
Show worked solution
1900 is not a leap year because it is divisible by 100 but not 400. The year 2000 is a leap year because it is divisible by 400. Therefore February 29 is invalid in 1900 and valid in 2000.
Check your solution
- 1900 is not a leap year
- 2000 is a leap year
10. Explain why a date-shape regex alone cannot validate 2025-02-29. Explain the boundary and expected result.
Show hint
The pattern counts digits but does not know month lengths.
Show worked solution
A pattern can confirm four digits, two digits, and two digits separated by hyphens, so this text matches the shape. It cannot establish that February 2025 has a twenty-ninth day. Apply calendar and leap-year validation after syntax validation.
Check your solution
- The text matches the shape
- The calendar date is rejected
11. Explain what Date.UTC does with February 29 in non-leap year 2025. Explain the boundary and expected result.
Show hint
Compare the resulting UTC components with the requested components.
Show worked solution
Date.UTC(2025, 1, 29) normalizes to March 1, 2025 because February has only 28 days. A validator must compare the resulting year, month, and day to the original components or validate month length directly; it must reject the original request.
Check your solution
- The result normalizes to March 1
- The original date is rejected
12. Validate a calendar month value of 13 before constructing an instant. Explain the boundary and expected result.
Show hint
The permitted month range is one through twelve.
Show worked solution
Reject month 13 as outside the calendar range. Date construction may normalize an out-of-range month into the next year, but that normalized result does not make the original date valid. Check the month independently before accepting the value.
Check your solution
- Month 13 is rejected
- Normalization is not treated as validation
13. Explain why a UTC round-trip validator must document handling of years 0 through 99.
Show hint
Date.UTC has special behavior for that numeric year range.
Show worked solution
Date.UTC treats numeric years 0 through 99 specially, so a naive round trip can compare against an unintended century. Either handle those years deliberately or restrict and document the supported range. Test the boundary of whichever policy is selected.
Check your solution
- The special year behavior is considered
- The supported range or handling is documented
14. Explain why two users can see different calendar dates for one stored instant.
Show hint
The users can display the same instant in different zones.
Show worked solution
The instant remains the same, but local offsets and zone rules can place it on different calendar days. For example, 00:30 UTC on January 1 can still be December 31 in New York. Specify each display zone and verify the stored UTC instant.
Check your solution
- The stored instant is unchanged
- Local calendar dates can differ
15. Display an instant for Tokyo without relying on the server local time zone.
Show hint
Pass an explicit named timeZone to Intl.DateTimeFormat.
Show worked solution
Construct Intl.DateTimeFormat with the intended locale and timeZone: "Asia/Tokyo", then format the validated instant. For stable assertions, inspect year, month, and day parts instead of assuming punctuation. Test in a runtime with the required internationalization and zone data.
Check your solution
- The zone is explicitly Asia/Tokyo
- Tests compare date components
16. Explain why one fixed offset cannot describe a named zone at every date.
Show hint
Zone rules can change historically or with daylight saving time.
Show worked solution
A named zone can use different offsets at different instants because of daylight-saving and historical changes. Store or specify the intended zone for local scheduling, and use its rules for the relevant date. Do not assume a single offset captures all future or past transitions.
Check your solution
- A named zone can have multiple offsets
- The relevant date and zone are specified
17. Describe a policy needed for a local scheduled time during a clock transition.
Show hint
A local time can be ambiguous or nonexistent.
Show worked solution
Store the intended local date and time with a named zone and define how to handle ambiguous or nonexistent times at transitions. Reject, ask for a choice, or use a documented resolution policy as appropriate. Test that policy with representative transition cases.
Check your solution
- The named zone is recorded
- Ambiguous and nonexistent times have a policy
18. Design tests for a date-only parser supporting years 1000 through 9999. Explain the boundary and expected result.
Show hint
Cover syntax, range, leap day, and year boundaries.
Show worked solution
Accept 2024-02-29 and the supported year boundaries when valid; reject 2025-02-29, month 13, malformed text, and years outside the documented range. Assert the returned calendar fields, not a zone-shifted display. Include the century leap-year cases in the suite.
Check your solution
- Valid leap day is accepted
- Invalid dates and out-of-range years are rejected
19. Design a test comparing one instant in UTC and New York near midnight.
Show hint
Use explicit zones and compare stable date components.
Show worked solution
Use 2025-01-01T00:30:00Z, assert UTC components are 2025-01-01, and assert New York components are 2024-12-31 with available zone data. The stored timestamp remains identical. Compare formatToParts fields rather than assuming locale punctuation.
Check your solution
- UTC date is 2025-01-01
- New York date is 2024-12-31
20. Explain why localized date display should be separate from stored instant or date-only data.
Show hint
Display formatting can vary without changing the underlying meaning.
Show worked solution
Store an instant in its documented timeline representation or a birthday as validated date-only fields, then format for the intended locale and zone. Localized strings can change punctuation and order; they should not replace the semantic storage contract or be reparsed as an implicit source of truth.
Check your solution
- Storage preserves the intended meaning
- Display specifies locale and zone when appropriate
Key takeaways
- Model date-only values separately from instants.
- Make validation, display zone, and scheduling policy explicit.
- A birthday does not by itself identify a unique instant.
- Date construction can normalize invalid components and is not sufficient validation.
- The same instant can appear on different dates in different zones.