ISO 8601 DateTime representation

╄→尐↘猪︶ㄣ 提交于 2020-06-27 16:17:49

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/44870006/iso-8601-datetime-representation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!