SwiftMoment icon indicating copy to clipboard operation
SwiftMoment copied to clipboard

Problem with date parsing

Open sgermain06 opened this issue 8 years ago • 1 comments

Problem with parsing time format

  • "h:mm:ss A",
  • "h:mm A",

Detailed Description

According to Apple's ISO descriptions, A represents microseconds, as opposed to AM/PM. Those formats should be changed to a rather than A.

Context

This causes issues for people trying to use SwiftMoment to represent times.

Possible Implementation

Change the formats to the following:

let formats = [
    isoFormat,
    "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'",
    "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'",
    "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
    "yyyy-MM-dd",
    "h:mm:ss A",
    "h:mm A",
    "h:mm:ss a",   <---
    "h:mm a",      <---
    "MM/dd/yyyy",
    "MMMM d, yyyy",
    "MMMM d, yyyy LT",
    "dddd, MMMM D, yyyy LT",
    "yyyyyy-MM-dd",
    "yyyy-MM-dd",
    "GGGG-[W]WW-E",
    "GGGG-[W]WW",
    "yyyy-ddd",
    "HH:mm:ss.SSSS",
    "HH:mm:ss",
    "HH:mm",
    "HH"
]

Your Environment

  • Version used: Latest
  • Operating System and version: iOS 9.0+
  • Link to your project:

sgermain06 avatar Jan 23 '17 18:01 sgermain06

"yyyy-MM-dd'T'HH:mm:ss.SSSZ"

That one worked for me. Had the same issue as you. I think a new version for cocoapods is needed urgently.

apsoftware123 avatar Feb 06 '17 18:02 apsoftware123