spdx / tools

SPDX Tools
Apache License 2.0
123 stars 68 forks source link

ISO 8601 date/time format #270

Closed rjb4standards closed 3 years ago

rjb4standards commented 3 years ago

I'm receiving an error Analysis exception processing SPDX file: Invalid date format: Unparseable date: "2021-03-14T14:33:03.680092Z" on Tag/Value Created: 2021-03-14T14:33:03.680092Z

Is ISO 8601 date/time format supported in spdx 2.2?

Thanks..

rjb4standards commented 3 years ago

Nevermind, it is clearly supported in spdx 2.2 but the online validation tool throws an exception on a valid iso 8601 UTC date. Sorry for not catching this sooner. RTFM, when in doubt.

goneall commented 3 years ago

From looking at the code, it looks like the problem is .680092 following the seconds.

In the spec, the format is stated as ISO 8601, but the data format is specified to only include up to the seconds.

I took a look at the Wikipedia page for ISO 8601 and could not find a reference for the sub-second format. @rjb4standards do you know if ISO 8601 supports this? If so, we should update both the spec and the tools.

In the interim, removing the .680092 should work around the issue.

rjb4standards commented 3 years ago

Thanks Gary: Looking at RFC 3339, which applies iso 8601, it appears the fractional component of time can be any number of digits; here's the BNF: from https://www.ietf.org/rfc/rfc3339.txt

5.6. Internet Date/Time Format

The following profile of ISO 8601 [ISO8601] dates SHOULD be used in new protocols on the Internet. This is specified using the syntax description notation defined in [ABNF].

date-fullyear = 4DIGIT date-month = 2DIGIT ; 01-12 date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on ; month/year time-hour = 2DIGIT ; 00-23 time-minute = 2DIGIT ; 00-59 time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second ; rules *time-secfrac = "." 1DIGIT** time-numoffset = ("+" / "-") time-hour ":" time-minute time-offset = "Z" / time-numoffset

partial-time = time-hour ":" time-minute ":" time-second [time-secfrac] full-date = date-fullyear "-" date-month "-" date-mday full-time = partial-time time-offset

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

I'll truncate to seconds - thanks for your help.

rjb4standards commented 3 years ago

Truncating at seconds solved the problem. Thanks Gary.

goneall commented 3 years ago

This has been fixed in the SPDX Java Library used by the online tools. Once the library is release, we can update the SPDX online tools to use the new version of the library to resolve this issue.

goneall commented 3 years ago

I added an issue to the SPDX spec to track the inconsistency.

zvr commented 3 years ago

I think fractional seconds should NOT be supported, since the spec clearly says the format is YYYY-MM-DDThh:mm:ssZ.

We should fix the wording to not imply that everything described in ISO=8601 is allowed. No Julian dates, no week dates, none of the extended parts (unknown/unspecified numbers, spring/summer/etc.), ...

rjb4standards commented 3 years ago

I can live with that change, this is how I'm doing it now: Created: 2021-03-17T14:18:27Z

goneall commented 3 years ago

I'm going to go ahead and close this issue since a related spec issue has been opened.