I am working on removing Foundation dependency and noticed that my logs are using incorrect TimeZone after I removed the last import. Shouldn't this still work with just FoundationEssentials?
let dateToFormat = Date.now
var timeZone = TimeZone.current
if timeZone.identifier == "GMT",
case var now = time_t(dateToFormat.timeIntervalSince1970),
case var timeinfo = tm(),
case _ = localtime_r(&now, &timeinfo),
let actualTimeZone = TimeZone(secondsFromGMT: timeinfo.tm_gmtoff)
{
timeZone = actualTimeZone
}
Can you share what platform you're running this code on? Looking at the implementation, TimeZone.current does have the functionality to find your current timezone preferences even without FoundationInternationalization (that's why it compiles without the import, FoundationEssentials offers the property). However, I think the value of your timezone preference may require FoundationInternationalization. I believe just FoundationEssentials processes GMT/UTC-based timezones (ex. GMT+5) but I believe you do need FoundationInternationalization loaded in your process if your preferences specify a named timezone (ex. America/Los_Angeles) since we need ICU to map the timezone names to offsets. @tinaliu does that match your expectations?
(If someone wants to get timezone info on Linux other than the current one then the appropriate file in /usr/share/zoneinfo can also be parsed when available, this is the structure of that file: https://linux.die.net/man/5/tzfile )