Skip to main content

3. Two Digit Years

The following requirements address the problems of ambiguity that two digit years cause:

Requirements

o Four-digit years are mandatory

Internet Protocols MUST generate four digit years in dates.

Correct Examples:

✅ 2002-07-15
✅ 1999-12-31

Incorrect Examples:

❌ 02-07-15
❌ 99-12-31

o Two-digit years are deprecated

The use of two-digit years is deprecated. If a two-digit year is received, it SHOULD only be accepted if misinterpretation will not cause a protocol or processing failure (for example, if used only for logging or tracing purposes).

o Handling three-digit years

Programs that use two-digit years may represent years after 1999 as three digits. This will occur if the program simply subtracts 1900 from the year without checking the number of digits. Programs that wish to robustly handle dates generated by such flawed software MAY add 1900 to three-digit years.

Example:

Flawed program output: 102 (representing year 2002)
Robust parsing: 102 + 1900 = 2002

o Handling non-numeric decade digits

Programs that use two-digit years may represent years after 1999 as ":0", ":1", ... ":9", ";0", .... This will occur if the program simply subtracts 1900 from the year and adds the decade digit to the US-ASCII character zero. Programs that wish to robustly handle dates generated by such flawed software SHOULD detect non-numeric decade digits and interpret them appropriately.

Example:

Flawed program output:
- '0' + 10 = ':' (representing 2000s, ASCII code 58)
- '0' + 11 = ';' (representing 2010s, ASCII code 59)

Robust parsing should recognize these patterns and convert correctly

Lessons from Y2K

The problems with two-digit years amply demonstrate why all dates and times used in Internet protocols MUST be fully qualified.


Implementation Recommendations

When generating dates

✅ Always use four-digit years: 2024-12-21
❌ Never use two digits: 24-12-21

When parsing dates

# Robust parsing example
def parse_year(year_str):
if len(year_str) == 4:
return int(year_str) # Correct four digits
elif len(year_str) == 2:
# Deprecated, for backward compatibility only
year = int(year_str)
if year < 70:
return 2000 + year
else:
return 1900 + year
elif len(year_str) == 3:
# Handle flawed software
return 1900 + int(year_str)
else:
raise ValueError("Invalid year format")

Warning: While this section describes how to handle two-digit years, this is for backward compatibility only. New implementations absolutely MUST NOT generate two-digit years.