2

Is this a valid ISO 8601 representation of DateTime?

20170704T09:30:00+0530

i.e. whether a combination of both the basic and extended formats can be used? Or should it only be either of these:

20170704T093000+0530
2017-07-04T09:30:00+05:30

2 Answers2

2

In Wikipedia, it says that a combined date and time representation can be in basic or extended format, but both date and time must use the same format.

In ISO 8601, there's no mention of a mixed representation as well - take a look the examples in section 4.3.2. Although I couldn't find an explicit statement about mixing formats, it seems to me that you can't mix basic and extended formats in the same representation.

That being said, I would say that a format like 20170704T09:30:00+0530 is not valid in ISO 8601.

  • Also is it better to use rfc3339 i.e. extended iso 8601 instead of just the basic 8601 for date time representation? – Ezil Kannan Jul 02 '17 at 12:56
  • I think it depends on the formats accepted by the applications you're working on. Actually, RFC 3339 is a [ISO 8601 "extension"](https://stackoverflow.com/a/522281/7605325) and accepts a complete representation of date and time, while ISO itself is more flexible. You must check the requirements of your system and choose accordingly. –  Jul 02 '17 at 13:00
1

While ISO6801-2004 doesn't allow mixing basic and extended representations, there's no clause in the 2004 revision that would explicitly forbid that.

This question will be addressed in the next revision of ISO8601 [1] which finally includes a Backus-Naur Form definition of a valid timestamp syntax.

(* 4.3.2 Complete representations *)
dateTimeOfDayBasic = calendarDateBasic, "T", timeCompleteBasic,
                     [ "Z" | UTCoffsetBasic ] ;
dateTimeOfDayExt   = calendarDateExt, "T", timeCompleteExt,
                     [ "Z" | UTCoffsetExt ] ;

[1] Draft 2016-10-26: https://www.loc.gov/standards/datetime/ISO_DIS%208601-1.pdf

salmin
  • 457
  • 3
  • 12