Skip to content

Commit

Permalink
Merge pull request #287 from drewnoakes/fix-build
Browse files Browse the repository at this point in the history
Use invariant culture when parsing IPTC dates/times
  • Loading branch information
drewnoakes authored May 7, 2021
2 parents b11c3d2 + 00f5a9e commit 12191fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions MetadataExtractor/Formats/Iptc/IptcDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ protected override bool TryGetTagName(int tagType, out string tagName)
return GetDate(TagDigitalDateCreated, TagDigitalTimeCreated);
}

private static readonly string[] _formats = { "yyyyMMddHHmmsszzz", "yyyyMMddHHmmss" };
private static readonly string[] _formats = { "yyyyMMddHHmmsszzzz", "yyyyMMddHHmmsszzz", "yyyyMMddHHmmss" };

private DateTimeOffset? GetDate(int dateTagType, int timeTagType)
{
Expand All @@ -252,7 +252,9 @@ protected override bool TryGetTagName(int tagType, out string tagName)
if (date == null || time == null)
return null;

if (DateTimeOffset.TryParseExact(date + time, _formats, null, DateTimeStyles.None, out DateTimeOffset result))
IFormatProvider provider = CultureInfo.InvariantCulture.DateTimeFormat;

if (DateTimeOffset.TryParseExact(date + time, _formats, provider, DateTimeStyles.None, out DateTimeOffset result))
return result;

return null;
Expand Down

0 comments on commit 12191fc

Please sign in to comment.