Skip to content

Better timestamp handling #147

@nagix

Description

@nagix

The following fields don't contain the time zone information, and are stored into directories as strings. This seems reasonable because applications will manage how to map those timestamps to the specific time zone by using Directory.getDate(int tagType, TimeZone timeZone).

  • ExifIFD0Directory.TAG_DATETIME
  • ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL
  • ExifSubIFDDirectory.TAG_DATETIME_DIGITIZED

On the other hand, the following fields don't contain the time zone information either, but are interpreted as UTC time and stored into directories as Date objects. Applications are not able to directly map them to other time zones even if they are specified in Directory.getDate(int tagType, TimeZone timeZone).

  • IccDirectory.TAG_PROFILE_DATETIME
  • PngDirectory.TAG_LAST_MODIFICATION_TIME
  • XmpDirectory.TAG_DATETIME_ORIGINAL
  • XmpDirectory.TAG_DATETIME_DIGITIZED

There is another issue with the following fields. IPTC data contains the time zone information, but it is included only in the time fields. So, the time fields and its corresponding date fields need to be handled together.

  • IptcDirectory.TAG_DATE_SENT and IptcDirectory.TAG_TIME_SENT
  • IptcDirectory.TAG_RELEASE_DATE and IptcDirectory.TAG_RELEASE_TIME
  • IptcDirectory.TAG_EXPIRATION_DATE and IptcDirectory.TAG_EXPIRATION_TIME
  • IptcDirectory.TAG_DATE_CREATED and IptcDirectory.TAG_TIME_CREATED
  • IptcDirectory.TAG_DIGITAL_DATE_CREATED and IptcDirectory.TAG_DIGITAL_TIME_CREATED
  • IptcDirectory.TAG_REFERENCE_DATE

The following fields represent a UTC timestamp, which are also need to be handled together.

  • GpsDirectory.TAG_DATE_STAMP and GpsDirectory.TAG_TIME_STAMP

Also, the following fields hold the sub-second values for the timestamps, and should be reflected in the corresponding Date objects.

  • ExifSubIFDDirectory.TAG_SUBSECOND_TIME
  • ExifSubIFDDirectory.TAG_SUBSECOND_TIME_ORIGINAL
  • ExifSubIFDDirectory.TAG_SUBSECOND_TIME_DIGITIZED

With that, my suggestion is as follows:

  • Store a timestamp value into a directory as a String object if it has no time zone data
  • Store a timestamp value into a directory as a Date object if it has time zone data
  • For separate date/time fields, store a date value and a time value separately as a String, but convert them to a single Date object and store it to the both fields once both values became available
  • For sub-second fields, reformat String objects for timestamps if they exists
  • If a timestamp has no time zone data, Directory.getDate(int tagType) returns UTC time
  • Directory.getDate(int tagType, TimeZone timeZone) returns the Date object in which the time zone is overwritten with the specified time zone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions