Skip to content

Date parsing fails with American timezones if locale isn't American #2

Description

@jonlidgard

See: https://developer.apple.com/library/archive/qa/qa1480/_index.html
My fix: (I'm UK based & parsing Barclays Bank ofx files which use the date format 20191217000000[-5:EST]

let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0) // not sure if this is required - need to test

let maybeDate = formats.reduce(nil as Date?) { result, format in

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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