You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// assume TimeZone.current returns GMT0 time zone
TimeZone.current == TimeZone(identifier: TimeZone.current.identifier)
returns true on macOS 10.12.6
returns false on Ubuntu 14.04
================================
The way I see it, is CFTimeZone internally assumes working only with tzfile version 1 format. macOS 10.12.6 uses version 1. Ubuntu 14.04 uses version 2.
it eventually calls _CFTimeZoneInit()
and subsequentially _CFReadBytesFromFile
which reads data from /usr/share/zoneinfo/GMT
and stores it in __CFTimeZone->data
/usr/share/zoneinfo/GMT on Ubuntu 14.04 is tzfile version 2, and on macOS 10.12.6 is version 1.
Keeping that in mind, let's look at TimeZone.current
Looking at behavior described in SR-5596, we see that TimeZone.current eventually calls CFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorSystemDefault, 0.0)
which in turn calls __CFTimeZoneCreateFixed
and there we can see that it's hardcoded to always generate tzfile version 1 representation of the data.
So, TimeZone.current always generates CFTimeZone with version 1 data structure,
while TimeZone(identifier: ) reads the data from the tzfile, so the version depends on the system.
And the last piece of the puzzle is __CFTimeZoneEqual which we can see compares the data of the two objects
if (!CFEqual(CFTimeZoneGetData(tz1), CFTimeZoneGetData(tz2))) return false;
which will have different version structure depending on how TimeZone was initialized
The text was updated successfully, but these errors were encountered:
Environment
Ubuntu 14.04 buggy
macOS 10.12.6 ok
swift-DEVELOPMENT-SNAPSHOT-2017-07-26-a
Additional Detail from JIRA
md5: 33e88247ef6c95bf7dfb391ff31f0175
relates to:
Issue Description:
returns
true
on macOS 10.12.6returns
false
on Ubuntu 14.04================================
The way I see it, is
CFTimeZone
internally assumes working only with tzfile version 1 format.macOS 10.12.6 uses version 1.
Ubuntu 14.04 uses version 2.
Now from the example above let's consider first
it eventually calls
_CFTimeZoneInit()
and subsequentially
_CFReadBytesFromFile
which reads data from
/usr/share/zoneinfo/GMT
and stores it in
__CFTimeZone->data
/usr/share/zoneinfo/GMT
on Ubuntu 14.04 is tzfile version 2, and on macOS 10.12.6 is version 1.Keeping that in mind, let's look at
TimeZone.current
Looking at behavior described in SR-5596, we see that
TimeZone.current
eventually callsCFTimeZoneCreateWithTimeIntervalFromGMT(kCFAllocatorSystemDefault, 0.0)
which in turn calls
__CFTimeZoneCreateFixed
and there we can see that it's hardcoded to always generate tzfile version 1 representation of the data.
So,
TimeZone.current
always generatesCFTimeZone
with version 1 data structure,while
TimeZone(identifier: )
reads the data from the tzfile, so the version depends on the system.And the last piece of the puzzle is
__CFTimeZoneEqual
which we can see compares the data of the two objectswhich will have different version structure depending on how
TimeZone
was initializedThe text was updated successfully, but these errors were encountered: