The Date-ing Game - NSSpain, Logroño, Rioja, September 2024
A fun journey through how we take something as simple as a single point in time and find all kinds of new and interesting ways to screw it up royally, especially within the Apple ecosystem.
.dateComponents([.hour, .minute], from: talkTime) let hour = timeComponents.hour print(hour) // prints "Optional(14)" let minute = timeComponents.minute print(minute) // prints "Optional(30)"
.dateComponents([.hour, .minute], from: talkTime) let hour = timeComponents.hour print(hour) // prints "Optional(14)" let minute = timeComponents.minute print(minute) // prints "Optional(30)" let second = timeComponents.second
.dateComponents([.hour, .minute], from: talkTime) let hour = timeComponents.hour print(hour) // prints "Optional(14)" let minute = timeComponents.minute print(minute) // prints "Optional(10)" let second = timeComponents.second print(second) // prints "nil"
gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thusrday, 19 September 2024" let islamicResult = islamicCalendar.date(from: components)! print(gregorianFormatter.string(from: islamicResult)) // prints "Saturday, 31 December 2585"
for hour in 0..<count { let updatedDate = Calendar.autoupdatingCurrent .date(byAdding: DateComponents(hour: hour), to: self)! let formatted = formatter.string(from: updatedDate) formattedHours.append(formatted) } return formattedHours }
for hour in 0..<count { let updatedDate = Calendar.autoupdatingCurrent .date(byAdding: DateComponents(hour: hour), to: self)! let formatted = formatter.string(from: updatedDate) formattedHours.append(formatted) } return formattedHours }
the given date components Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)
March 10 2024 01:00 March 9 2024 26:00 -> March 10 2024 02:00 -> Does not exist, what's the closest match? -> March 10 2024 03:00 March 9 2024 27:00 -> March 10 2024 03:00
March 10 2024 01:00 March 9 2024 26:00 -> March 10 2024 02:00 -> Does not exist, what's the closest match? -> March 10 2024 03:00 March 9 2024 27:00 -> March 10 2024 03:00 -> March 10 2024 03:00
March 10 2024 01:00 March 9 2024 26:00 -> March 10 2024 02:00 -> Does not exist, what's the closest match? -> March 10 2024 03:00 ! March 9 2024 27:00 -> March 10 2024 03:00 -> March 10 2024 03:00 ! .
the given date components Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)
the given date components Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) /// Take the passed-in date and add the passed-in components Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)
as numeric offsets from a specific point in time > Humans think about dates in a lot of different ways > Let ! handle as much of this for you as possible
as numeric offsets from a specific point in time > Humans think about dates in a lot of different ways > Let ! handle as much of this for you as possible > Use date and time styles rather than specific formats if you're displaying a date to a user
as numeric offsets from a specific point in time > Humans think about dates in a lot of different ways > Let ! handle as much of this for you as possible > Use date and time styles rather than specific formats if you're displaying a date to a user > Test the crap out of transition points
to displaying content humans understand across the world > https://www.youtube.com/watch?v=-5wpm-gesOY - Tom Scott from 2013 on the Problem With Time And Time Zones, capturing the exasperation beautifully > https://goshdarnformatstyle.com/ - A guide to SwiftUI FormatStyle funtimes
ESA made for coming up with a lunar time zone > https://www.smithsonianmag.com/smart-news/the- moon-will-get-its-own-time-zone-called-coordinated- lunar-time-under-nasas-lead-180984076/, a very readable summary of the effort that will be led by
fine listing of just a few of the many, many, many ways to screw up dates, times, and calendars. > https://vimeo.com/865876497, his 2023 NSSpain talk "The Temporal Axis of Space-Time" drawing parallels between how we think about space and how we think about time