Unix operating systems originally had a system time that was based on a number of seconds since midnight on January 1st 1970. Every Apple operating system has at its core a Unix kernel called Darwin. That’s why Date().timeIntervalSince1970
exists.
Sometimes it’s useful to be able to convert between Unix time and regular time, I’ve made a converter between the two.
There’s a NumberFormatter
here that allows me to create a TextField
later that can only display integers.
There’s a timeZoneOffsetString
that allows me to display the hours that the local time zone is away from UTC, which confusingly stands for Coordinated Universal Time.
situating-sinologiesThe reason according to the National Institute of Standards and Technology:
In 1970, the Coordinated Universal Time system was devised by an international advisory group of technical experts within the International Telecommunication Union (ITU). The ITU felt it was best to designate a single abbreviation for use in all languages in order to minimize confusion. For example, in English the abbreviation for coordinated universal time would be CUT, while in French the abbreviation for "temps universel coordonné" would be TUC. To avoid appearing to favor any particular language, the abbreviation UTC was selected.
At the top of my Form is the TextField
for the Unix time, sometimes called a timestamp.
There’s a DatePicker
that is given the .environment(\.timeZone, .gmt)
modifier. This changes an environment variable that sets the time zone to Greenwich Mean Time, which is “the mean solar time at the Royal Observatory in Greenwich, London, counted from midnight”. This gives an indication of where this time zone is located, but it is now more commonly referred to as the aforementioned UTC.
Although I am in the UK, this is still not the time currently being observed here.
The current UK time zone is British Summer Time, which is UTC +1.
I’ve provided another DatePicker
that will display the Unix timestamp as it would be in your time zone. As British Summer Time currently adds an hour to UTC, my DatePicker
is only different by one hour. Note that each DatePicker
can have the same Binding<Date>
, because only the UTC date has the .environment(\.timeZone, .gmt)
modifier.