Closed helje5 closed 4 years ago
I'm a +1 on this and think that we should address it. @tomerd wdyt?
+1 conceptually - I dont like the 10.13 constraint either.
do we know if this can be done in all formats coming form AWS? I think foundation used ICU for some timezone localization aspects which may be more complicated than the one demonstrated here, but it may not be used here
? It’s ISO, there are only really two variants, with ms and without
Oh, timezones, this format doesn’t support timezones (anything locale bound requiring tzdata) , max gmt offsets, though it probably is Z always
right, but IIRC there are other date formats we deal with in the library (unfortunately different AWS events have different date formats) so trying to understand if we can get away with this in all cases
neither dateformatter nor locale require 10.13, it is just the specific isodateformatter, and iso is fixed
works for me!
@tomerd We can go full strptime
here or we just create a DateFormatter
that has the iso as the dateFormat
string like here:
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
date formatters are really really slow, i kicked them out of shrugs because they have been taking like 40% of the startup time. they are locale aware which is zarro necessary here
i think strptime is fine, but the ms need to be handled separately
ugh, looks like strptime
not avail on through Glibc. I guess I could make this Darwin only since we will use the formatters in linux anyways
The runtime requires macOS 10.13, which is quite inconvenient because all consuming packages now also need to explicitly require 10.13 in the package manifest. It is especially annoying if one tries to conditionally implement Lambda support in a 10.10 package via
#canImport
, e.g.: https://github.com/Macro-swift/Macro/blob/feature/lambda-1/Sources/http/Lambda/lambda.swift#L9Slack says this requirement only exists for the ISO date formatter, not sure whether you use it for rendering only or also for parsing. In any case, it should be quite easy to replace w/ a custom parser/renderer. Should be reasonable because the format is fixed and never changes.
It could be built on top of
timegm
andstrptime
, though it needs an extra processing step to capture the milliseconds:You could also provide this, and still use the ISO formatter if available (via
if #available(macOS 10.13, ...)
), which is what I do in Macro.