Search code examples
rfc3339

What are valid date-time separators in RFC3339 strings?


I'm quite confused as to what's allowed as the time separator/designator in the RFC3339 standard. By time separator I mean the sequence of characters that draw the line between date and time.

The standard states in section 5.6 different things that are unclear or conflicting. First of all, it says that the production rule for a full datetime is this:

date-time = full-date "T" full-time

Meaning that the delimiter between the date and the time is an uppercase T. Right after comes this:

  NOTE: Per [ABNF] and ISO8601, the "T" and "Z" characters in this
  syntax may alternatively be lower case "t" or "z" respectively

Meaning the upper case T may be a lower case t. It conflicts with the ABNF, but OK, it stills sounds to me within the realm of reasonable. Then the following is stated

  NOTE: ISO 8601 defines date and time separated by "T".
  Applications using this syntax may choose, for the sake of
  readability, to specify a full-date and full-time separated by
  (say) a space character.

Which is very confusing. Does this allow not only a space character but anything? which is what this say implies. Or does it by this syntax refer to ISO8601 and unnecessarily describes a detail of that other standard?

In other words, are the following valid RFC3339 strings?

  • 2020-09-07 20:26:03.623359300+02:00
  • 2020-09-07hey johnny20:26:03.623359300+02:00
  • 2020-09-07💩20:26:03.623359300+02:00

Solution

  • Short answer: T (or t as discouraged alternative).

    After reading on this as much as I could, it turns out the time separator must be a T or t. What has made think this way is first of all this thread in the GNU lists where F. Alexander Njemz contacted the authors of RFC3339 Graham Klyne and Chris Newman asking if T is mandatory and got this response from Mr. Klyne:

    In short: "yes"

    Per section 5.5, the intent in this draft was to specify a timestamp format using elements from and compatible with 8601, but eliminating as far as reasonable any variations that could make timestamp data harder to process. This includes making the 'T' mandatory in date+time values.

    #g

    Just for clarity's sake, this is stated in the section 5.5:

    Simplicity is achieved by making most fields and punctuation mandatory.

    This clearly clashes with a non-mandatory T and strongly makes me think that the this syntax in that problematic passage refers to ISO8601 and not RFC3339.

    For those who want to read more, here are some links regarding the confusion created by this specific point:

    Plus of course divergent implementations. For instance, the developers of GNU Date chose to use a space character:

    $ date --rfc-3339=seconds
    2020-09-14 14:53:51+02:00