Description
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#L9
Slack 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
and strptime
, though it needs an extra processing step to capture the milliseconds:
import func Foundation.strptime
import func Foundation.timegm
import struct Foundation.tm
let s = "20180905T140903.591680Z"
var parsedTime = tm()
s.withCString { cstr in
strptime(cstr, "%Y%m%dT%H%M%S.%fZ", &parsedTime) // this needs to extract the ms
}
let time = timegm(&parsedTime)
let ti = TimeInterval(time) // + 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.