Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly disallow year 0 #1000

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Explicitly disallow year 0 #1000

wants to merge 1 commit into from

Commits on Oct 13, 2023

  1. Explicitly disallow year 0

    Year "0" doesn't exist; it goes from 1 BC to 1 AD.
    
    RFC 3339 is somewhat unclear if this should be allowed, at least in my
    reading of it:
    
    > This document defines a [..] representation of dates and times using
    > the Gregorian calendar.
    
    "Gregorian calendar" has no "year zero", so it should be forbidden. But
    also:
    
    > All dates and times are assumed to be in the "current era",
    > somewhere between 0000AD and 9999AD.
    
    So meh.
    
    Practically speaking, supporting this across the board is rather tricky.
    Python's datetime has no way to represent this (other than None, maybe?
    Ugh.), PostgreSQL doesn't support it, Go's time.Time behaves oddly (e.g.
    IsZero() is false, which is rather surprising), etc.
    
    ISO 8601 defines year 0 as "1 BC", which is even worse since most
    datetime implementations don't really do BC dates.
    
    Just forbidding it is by far the easiest for everyone; for
    implementations with a datetime that supports it, it's just a single
    `if`, and for e.g. Python nothing needs to be done.
    
    The only potential downside is that people may have `d = 0000-01-01`. We
    already broke compatibility "for sanity" by disallowing table overrides,
    so I think that's okay. The alternative is making it implementation
    dependent. Meh.
    
    RFC 3339 is supposed to be a "ISO 8601, without obscure edge cases";
    this seems to fit with the intended purpose.
    arp242 committed Oct 13, 2023
    Configuration menu
    Copy the full SHA
    20e87a0 View commit details
    Browse the repository at this point in the history