trimmer-io / go-xmp

A native Go SDK for the Extensible Metadata Platform (XMP)
Apache License 2.0
54 stars 11 forks source link

doesn't correctly handle dates without time zones #8

Open rothskeller opened 3 years ago

rothskeller commented 3 years ago

According to the XMP Specification, Part I, section 8.2.1.2, "the time zone designator need not be present in XMP. When not present, the time zone is unknown, and an XMP processor should not assume anything about the missing time zone."

The go-xmp library parses time fields (e.g. xmp:CreateDate) using the Go time.Parse function, which assumes UTC if it doesn't see a time zone. More fundamentally, the library stores time fields in a Go time.Time structure, which has no way to represent a time without a time zone. There's no way for a library user to tell that the time zone is unknown. As a result, a photo viewer could be showing a "local" time that is many hours off from the correct one.

Since XMP times cannot be faithfully represented in a Go time.Time, it would be best to leave them in string form, and provide the conversion routines as separate functions.