Skip to content

Commit

Permalink
Merge pull request #275 from loopandlearn/date-parsing-issue
Browse files Browse the repository at this point in the history
Fix date parsing issue for 12/24-hour formats
  • Loading branch information
marionbarker committed Mar 29, 2024
2 parents 02c0b16 + 52504ad commit cd66a28
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LoopFollow/helpers/NightscoutUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ class NightscoutUtils {
let dateFormatterWithMilliseconds = DateFormatter()
dateFormatterWithMilliseconds.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
dateFormatterWithMilliseconds.timeZone = TimeZone(abbreviation: "UTC")
dateFormatterWithMilliseconds.locale = Locale(identifier: "en_US_POSIX")

let dateFormatterWithoutMilliseconds = DateFormatter()
dateFormatterWithoutMilliseconds.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
dateFormatterWithoutMilliseconds.timeZone = TimeZone(abbreviation: "UTC")
dateFormatterWithoutMilliseconds.locale = Locale(identifier: "en_US_POSIX")

if let date = dateFormatterWithMilliseconds.date(from: dateString) {
return date
Expand All @@ -205,4 +207,5 @@ class NightscoutUtils {

return nil
}

}

0 comments on commit cd66a28

Please sign in to comment.