Skip to content

Commit

Permalink
Use invariant culture when parsing IPTC dates/times
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed May 7, 2021
1 parent ab4a15b commit 00f5a9e
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 00f5a9e

Please sign in to comment.