Slide 1

Slide 1 text

THE DATE-ING GAME NSSPAIN | LOGROÑO, RIOJA | SEPTEMBER 2024 ELLEN SHAPIRO | MASTODON.SOCIAL/@DESIGNATEDNERD | PIXITEAPPS.COM

Slide 2

Slide 2 text

TIME SEEMS EASY

Slide 3

Slide 3 text

TIME SEEMS EASY ( SPOILER ALERT: IT IS NOT )

Slide 4

Slide 4 text

let now = Date()

Slide 5

Slide 5 text

60 * 60

Slide 6

Slide 6 text

60 * 60 * 24

Slide 7

Slide 7 text

60 * 60 * 24 * 365

Slide 8

Slide 8 text

let now = Date.now let oneYear = TimeInterval(60 * 60 * 24 * 365) let oneYearLater = now.addingTimeInterval(oneYear) print("Now: \(now).\nOne year from now: \(oneYearLater)")

Slide 9

Slide 9 text

let now = Date.now let oneYear = TimeInterval(60 * 60 * 24 * 365) let oneYearLater = now.addingTimeInterval(oneYear) print("Now: \(now).\nOne year from now: \(oneYearLater)")

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

!

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

DATE

Slide 14

Slide 14 text

THE ! DEFINITION A specific point in time, independent of any calendar or time zone.

Slide 15

Slide 15 text

MY DEFINITION A fixed point in time

Slide 16

Slide 16 text

.timeIntervalSince1970

Slide 17

Slide 17 text

.timeIntervalSince1970 .timeIntervalSinceReferenceDate

Slide 18

Slide 18 text

.timeIntervalSince1970 00:00:00 UTC on 1 January 1970 .timeIntervalSinceReferenceDate

Slide 19

Slide 19 text

.timeIntervalSince1970 00:00:00 UTC on 1 January 1970 .timeIntervalSinceReferenceDate 00:00:00 UTC on 1 January 2001

Slide 20

Slide 20 text

INT32

Slide 21

Slide 21 text

https://en.wikipedia.org/wiki/Year_2038_problem

Slide 22

Slide 22 text

https://en.wikipedia.org/wiki/Year_2038_problem

Slide 23

Slide 23 text

.timeIntervalSince1970 00:00:00 UTC on 1 January 1970 .timeIntervalSinceReferenceDate 00:00:00 UTC on 1 January 2001 .timeIntervalBetween1970AndReferenceDate

Slide 24

Slide 24 text

.timeIntervalSince1970 00:00:00 UTC on 1 January 1970 .timeIntervalSinceReferenceDate 00:00:00 UTC on 1 January 2001 .timeIntervalBetween1970AndReferenceDate 978,307,200 seconds

Slide 25

Slide 25 text

previousSeconds += 1

Slide 26

Slide 26 text

! !

Slide 27

Slide 27 text

CALENDAR

Slide 28

Slide 28 text

THE ! DEFINITION A definition of the relationships between calendar units and absolute points in time, providing features for calculation and comparison of dates

Slide 29

Slide 29 text

MY DEFINITION The only way to relate an absolute point in time to anything humans will actually be able to understand

Slide 30

Slide 30 text

404 DAY NOT FOUND

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Calendar.Identifier.gregorian

Slide 33

Slide 33 text

Painted by Bartolomeo Passarotti

Slide 34

Slide 34 text

! !

Slide 35

Slide 35 text

!

Slide 36

Slide 36 text

365.25

Slide 37

Slide 37 text

365.2425

Slide 38

Slide 38 text

Painted by Bartolomeo Passarotti

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

Calendar.Identifier.japan

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

!

Slide 44

Slide 44 text

Calendar.identifier.hebrew Calendar.idenfier.islamic Calendar.identifier.chinese Calendar.identifier.indian

Slide 45

Slide 45 text

DO NOT TRY THIS (MANUALLY) AT HOME

Slide 46

Slide 46 text

Calendar(identifier: .gregorian)

Slide 47

Slide 47 text

Calendar.autoupdatingCurrent

Slide 48

Slide 48 text

DATE FORMATTER

Slide 49

Slide 49 text

THE ! DEFINITION Instances of DateFormatter create string representations of Date objects, and convert textual representations of dates and times into Date objects.

Slide 50

Slide 50 text

MY DEFINITION The thing you should use to turn a Date into a user-facing string.

Slide 51

Slide 51 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent

Slide 52

Slide 52 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent print(formatter.string(from: now))

Slide 53

Slide 53 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent print(formatter.string(from: now)) // prints: (nothing!)

Slide 54

Slide 54 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent formatter.dateFormat = "MM-dd-yyyy" print(formatter.string(from: now)) // prints: "09-19-2024"

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent formatter.dateStyle = .full print(formatter.string(from: now)) // prints: "Thursday, 19 September 2024"

Slide 57

Slide 57 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent formatter.dateStyle = .full print(formatter.string(from: now)) // prints: "Thursday, 19 September 2024" formatter.locale = Locale(identifier: "en_US")

Slide 58

Slide 58 text

let now = Date() let formatter = DateFormatter() formatter.calendar = Calendar.autoupdatingCurrent formatter.dateStyle = .full print(formatter.string(from: now)) // prints: "Thursday, 19 September 2024" formatter.locale = Locale(identifier: "en_US") print(formatter.string(from: now)) // prints: "Thursday, September 19 2024"

Slide 59

Slide 59 text

let now = Date() let aucFormatter = DateFormatter() aucFormatter.calendar = Calendar.autoupdatingCurrent print(formatter.string(from: now)) // prints: "Thursday, 19 September 2024" let islamicFormatter = DateFormatter() islamicFormatter.calendar = Calendar(identifier: .islamic)

Slide 60

Slide 60 text

let now = Date() let aucFormatter = DateFormatter() aucFormatter.calendar = Calendar.autoupdatingCurrent print(formatter.string(from: now)) // prints: "Thursday, 19 September 2024" let islamicFormatter = DateFormatter() islamicFormatter.calendar = Calendar(identifier: .islamic) islamicFormatter.dateStyle = .full // prints "Thursday, Rabiʻ I 16, 1446 AH"

Slide 61

Slide 61 text

let now = Date() let aucFormatter = DateFormatter() aucFormatter.calendar = Calendar.autoupdatingCurrent print(formatter.string(from: now)) // prints: "Friday, 19 January 2024" let islamicFormatter = DateFormatter() islamicFormatter.calendar = Calendar(identifier: .islamic) islamicFormatter.dateStyle = .full print(islamicFormatter.string(from: now)) // prints "Thursday, Rabiʻ I 16, 1446 AH" islamicFormatter.locale = Locale(identifier: "en_GB") print(islamicFormatter.string(from: now)) // prints "Thursday, 16 Rabiʻ I 1446 AH"

Slide 62

Slide 62 text

OTHER USEFUL DATE FORMATTERS

Slide 63

Slide 63 text

OTHER USEFUL DATE FORMATTERS > DateIntervalFormatter

Slide 64

Slide 64 text

OTHER USEFUL DATE FORMATTERS > DateIntervalFormatter > DateComponentsFormatter

Slide 65

Slide 65 text

OTHER USEFUL DATE FORMATTERS > DateIntervalFormatter > DateComponentsFormatter > ISO8601DateFormatter

Slide 66

Slide 66 text

OTHER USEFUL DATE FORMATTERS > DateIntervalFormatter > DateComponentsFormatter > ISO8601DateFormatter > RelativeDateTimeFormatter *

Slide 67

Slide 67 text

OTHER USEFUL DATE FORMATTERS > DateIntervalFormatter > DateComponentsFormatter > ISO8601DateFormatter > RelativeDateTimeFormatter * * swift only

Slide 68

Slide 68 text

FORMATSTYLE

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

GOSHDARN FORMATSTYLE.COM

Slide 71

Slide 71 text

DATE COMPONENTS

Slide 72

Slide 72 text

THE ! DEFINITION A date or time specified in terms of units (such as year, month, day, hour, and minute) to be evaluated in a calendar system and time zone.

Slide 73

Slide 73 text

MY DEFINITION How to define which parts of a date you actually care about

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

dateComponents(_ components: Set, from date: Date) -> DateComponents date(from: DateComponents) -> Date

Slide 76

Slide 76 text

GETTING COMPONENTS OUT OF A DATE

Slide 77

Slide 77 text

let talkTime = ISO8601DateFormatter() .date(from: "2024-09-19T14:30:00+02:00")!

Slide 78

Slide 78 text

let talkTime = ISO8601DateFormatter() .date(from: "2024-09-19T14:30:00+02:00")! let timeComponents = gregorianCalendar .dateComponents([.hour, .minute], from: talkTime)

Slide 79

Slide 79 text

let talkTime = ISO8601DateFormatter() .date(from: "2024-09-19T14:30:00+02:00")! let timeComponents = gregorianCalendar .dateComponents([.hour, .minute], from: talkTime) let hour = timeComponents.hour print(hour) // prints "Optional(14)" let minute = timeComponents.minute print(minute) // prints "Optional(30)"

Slide 80

Slide 80 text

let talkTime = ISO8601DateFormatter() .date(from: "2024-09-19T14:30:00+02:00")! let timeComponents = gregorianCalendar .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

Slide 81

Slide 81 text

let talkTime = ISO8601DateFormatter() .date(from: "2024-09-19T14:30:00+02:00")! let timeComponents = gregorianCalendar .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"

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

TURNING COMPONENTS INTO A DATE

Slide 84

Slide 84 text

let components = DateComponents(year: 2024, month: 9, day: 19)

Slide 85

Slide 85 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult))

Slide 86

Slide 86 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024"

Slide 87

Slide 87 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! gregorianFormatter.timeStyle = .short print(gregorianFormatter.string(from: gregorianResult))

Slide 88

Slide 88 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! gregorianFormatter.timeStyle = .short print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024 at 12:00AM"

Slide 89

Slide 89 text

let components = DateComponents(year: 2024) let gregorianResult = gregorianCalendar.date(from: components)! gregorianFormatter.timeStyle = .short print(gregorianFormatter.string(from: gregorianResult)) // prints "Monday, 1 January 2024 at 12:00 AM"

Slide 90

Slide 90 text

let components = DateComponents(year: 2024, month: 9, day: 19, hour: 14, minute: 30) let gregorianResult = gregorianCalendar.date(from: components)! gregorianFormatter.timeStyle = .short print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024 at 2:30 PM"

Slide 91

Slide 91 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024"

Slide 92

Slide 92 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024" let islamicResult = islamicCalendar.date(from: components)!

Slide 93

Slide 93 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024" let islamicResult = islamicCalendar.date(from: components)! print(gregorianFormatter.string(from: islamicResult))

Slide 94

Slide 94 text

let components = DateComponents(year: 2024, month: 9, day: 19) let 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"

Slide 95

Slide 95 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024" let islamicResult = islamicCalendar.date(from: components)! print(gregorianFormatter.string(from: islamicResult)) // prints "Saturday, 31 December 2585" print(islamicFormatter.string(from: islamicResult))

Slide 96

Slide 96 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024" let islamicResult = islamicCalendar.date(from: components)! print(gregorianFormatter.string(from: islamicResult)) // prints "Saturday, 31 December 2585" print(islamicFormatter.string(from: islamicResult)) // prints "Saturday, 19 Ramadan 2024 AH"

Slide 97

Slide 97 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 19 September 2024" let islamicResult = islamicCalendar.date(from: components)! print(gregorianFormatter.string(from: islamicResult)) // prints "Saturday, 31 December 2585" print(islamicFormatter.string(from: islamicResult)) // prints "Saturday, 19 Ramadan 2024 AH"

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

¯\_(ツ)_/¯

Slide 100

Slide 100 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 9 September 2024 print(islamicFormatter.string(from: gregorianResult)) // prints "Thursday, Rabiʻ I 16, 1446 AH"

Slide 101

Slide 101 text

let components = DateComponents(year: 2024, month: 9, day: 19) let gregorianResult = gregorianCalendar.date(from: components)! print(gregorianFormatter.string(from: gregorianResult)) // prints "Thursday, 9 September 2024 print(islamicFormatter.string(from: gregorianResult)) // prints "Thursday, Rabiʻ I 16, 1446 AH"

Slide 102

Slide 102 text

.timeIntervalSince1970 00:00:00 UTC on 1 January 1970 .timeIntervalSinceReferenceDate 00:00:00 UTC on 1 January 2001 .timeIntervalBetween1970AndReferenceDate 978,307,200 seconds

Slide 103

Slide 103 text

UTC

Slide 104

Slide 104 text

UTC COORDINATED UNIVERSAL TIME

Slide 105

Slide 105 text

UTC UNIVERSAL TIME, COORDINATED!

Slide 106

Slide 106 text

TIME ZONE

Slide 107

Slide 107 text

THE ! DEFINITION Information about standard time conventions associated with a specific geopolitical region.

Slide 108

Slide 108 text

MY DEFINITION The way humans reconcile the rotation of the earth and a need to coordinate time across physical and political boundaries

Slide 109

Slide 109 text

!

Slide 110

Slide 110 text

BOSTON: 71.0552° W NYC: 73.9935° W

Slide 111

Slide 111 text

! ⌚

Slide 112

Slide 112 text

! "

Slide 113

Slide 113 text

! GMT

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

No content

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

360 / 24 = 15

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

!

Slide 121

Slide 121 text

https://www.bbc.com/news/world-asia-16351377

Slide 122

Slide 122 text

No content

Slide 123

Slide 123 text

MY DEFINITION The way humans reconcile the rotation of the earth and a need to coordinate time across physical and political boundaries

Slide 124

Slide 124 text

MY DEFINITION The way humans reconcile the rotation of the earth* and a need to coordinate time across physical and political boundaries * - mostly

Slide 125

Slide 125 text

LTC COORDINATED LUNAR TIME

Slide 126

Slide 126 text

https://www.esa.int/Applications/Satellite_navigation/Telling_time_on_the_Moon

Slide 127

Slide 127 text

[https://www.whitehouse.gov/wp-content/uploads/2024/04/Celestial-Time-Standardization-Policy.pdf

Slide 128

Slide 128 text

SERIOUSLY, DO NOT TRY THIS (MANUALLY) AT HOME

Slide 129

Slide 129 text

let allTimeZones = TimeZone.knownTimeZoneIdentifiers .compactMap { TimeZone(identier: $0) }

Slide 130

Slide 130 text

https://commons.wikimedia.org/wiki/File:China_%E2%80%93_U.S._area_comparison.jpg

Slide 131

Slide 131 text

No content

Slide 132

Slide 132 text

No content

Slide 133

Slide 133 text

TimeZone.autoupdatingCurrent

Slide 134

Slide 134 text

let utcTimeZone = TimeZone(identifier: "UTC")!

Slide 135

Slide 135 text

No content

Slide 136

Slide 136 text

No content

Slide 137

Slide 137 text

No content

Slide 138

Slide 138 text

No content

Slide 139

Slide 139 text

No content

Slide 140

Slide 140 text

No content

Slide 141

Slide 141 text

let utcTimeZone = TimeZone(identifier: "UTC")! print(utcTimeZone.identifier)

Slide 142

Slide 142 text

let utcTimeZone = TimeZone(identifier: "UTC")! print(utcTimeZone.identifier) // prints: "GMT"

Slide 143

Slide 143 text

TimeZone.secondsFromGMT(for: Date)

Slide 144

Slide 144 text

GENERAL ADVICE

Slide 145

Slide 145 text

STORE ONLY THE COMPONENTS YOU NEED

Slide 146

Slide 146 text

https://www.pixiteapps.com/apps/planner-journal-zinnia

Slide 147

Slide 147 text

No content

Slide 148

Slide 148 text

THIS IS VERY EASY TO OVERTHINK

Slide 149

Slide 149 text

THIS IS ALSO VERY EASY TO UNDERESTIMATE

Slide 150

Slide 150 text

TEST YOUR DATES AND TIMES

Slide 151

Slide 151 text

CREATING A DATE IN ONE TIME ZONE READING IT IN ANOTHER

Slide 152

Slide 152 text

WATCH OUT FOR WHAT TIME YOUR CI THINKS IT IS

Slide 153

Slide 153 text

ONE COMPONENT IS SUDDENLY LOWER

Slide 154

Slide 154 text

ONE COMPONENT IS SUDDENLY LOWER > Day Rollovers

Slide 155

Slide 155 text

ONE COMPONENT IS SUDDENLY LOWER > Day Rollovers > Month Rollovers

Slide 156

Slide 156 text

ONE COMPONENT IS SUDDENLY LOWER > Day Rollovers > Month Rollovers > Year Rollovers

Slide 157

Slide 157 text

OCCASIONAL WEIRDNESS

Slide 158

Slide 158 text

OCCASIONAL WEIRDNESS > Leap Year Rollovers

Slide 159

Slide 159 text

OCCASIONAL WEIRDNESS > Leap Year Rollovers > Years With Extra Months in Lunisolar Calendars

Slide 160

Slide 160 text

OCCASIONAL WEIRDNESS > Leap Year Rollovers > Years With Extra Months in Lunisolar Calendars > Daylight Savings Time Rollovers

Slide 161

Slide 161 text

THINGS I SCREWED UP EVEN AS I WROTE THIS TALK

Slide 162

Slide 162 text

CALENDAR + DATECOMPONENTS Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)

Slide 163

Slide 163 text

No content

Slide 164

Slide 164 text

extension Date { func formattedNextHoursAdjsutingComponents(count: Int) -> [String] { var components = Calendar.autoupdatingCurrent .dateComponents([.year, .month, .day, .hour, .minute], from: self) let originalHour = components.hour! var formattedHours = [String]() for hour in 0..

Slide 165

Slide 165 text

extension Date { func formattedNextHoursAdjsutingComponents(count: Int) -> [String] { var components = Calendar.autoupdatingCurrent .dateComponents([.year, .month, .day, .hour, .minute], from: self) let originalHour = components.hour! var formattedHours = [String]() for hour in 0..

Slide 166

Slide 166 text

func formattedNextHoursAddingComponents(count: Int) -> [String] { var formattedHours = [String]() for hour in 0..

Slide 167

Slide 167 text

func formattedNextHoursAddingComponents(count: Int) -> [String] { var formattedHours = [String]() for hour in 0..

Slide 168

Slide 168 text

let now = Date() let nowAdjustingComponents = now .formattedNextHoursAdjustingComponents(count: 12) .joined(separator: "\n") let nowAddingComponents = now .formattedNextHoursAddingComponents(count: 12) .joined(separator: "\n")

Slide 169

Slide 169 text

// March 9, 2024 at 7pm Eastern Time let springForward = ISO8601DateFormatter().date(from: "2024-03-10T00:00:00Z")! formatter.timeZone = TimeZone(identifier: "America/New_York")! let springForwardAdjustingComponents = springForward .formattedNextHoursAdjustingComponents(count: 12) .joined(separator: "\n") let springForwardAddingComponents = springForward .formattedNextHoursAddingComponents(count: 12) .joined(separator: "\n")

Slide 170

Slide 170 text

NOW

Slide 171

Slide 171 text

ADJUSTING ADDING

Slide 172

Slide 172 text

ADJUSTING ADDING ✅

Slide 173

Slide 173 text

SPRING FORWARD

Slide 174

Slide 174 text

ADJUSTING ADDING

Slide 175

Slide 175 text

ADJUSTING ADDING

Slide 176

Slide 176 text

ADJUSTING ADDING

Slide 177

Slide 177 text

ADJUSTING ADDING

Slide 178

Slide 178 text

ADJUSTING ADDING ❌

Slide 179

Slide 179 text

No content

Slide 180

Slide 180 text

No content

Slide 181

Slide 181 text

No content

Slide 182

Slide 182 text

CALENDAR + DATECOMPONENTS Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)

Slide 183

Slide 183 text

CALENDAR + DATECOMPONENTS Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)

Slide 184

Slide 184 text

CALENDAR + DATECOMPONENTS /// Find the closest matching date to the given date components Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)

Slide 185

Slide 185 text

March 9 2024 25:00

Slide 186

Slide 186 text

March 9 2024 25:00 -> March 10 2024 01:00

Slide 187

Slide 187 text

March 9 2024 25:00 -> March 10 2024 01:00 -> March 10 2024 01:00

Slide 188

Slide 188 text

March 9 2024 25:00 -> March 10 2024 01:00 -> March 10 2024 01:00 March 9 2024 26:00

Slide 189

Slide 189 text

March 9 2024 25:00 -> March 10 2024 01:00 -> March 10 2024 01:00 March 9 2024 26:00 -> March 10 2024 02:00 ->

Slide 190

Slide 190 text

March 9 2024 25:00 -> March 10 2024 01:00 -> March 10 2024 01:00 March 9 2024 26:00 -> March 10 2024 02:00 -> Does not exist, what's the closest match?

Slide 191

Slide 191 text

March 9 2024 25:00 -> March 10 2024 01: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

Slide 192

Slide 192 text

March 9 2024 25:00 -> March 10 2024 01: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

Slide 193

Slide 193 text

March 9 2024 25:00 -> March 10 2024 01: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

Slide 194

Slide 194 text

March 9 2024 25:00 -> March 10 2024 01: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

Slide 195

Slide 195 text

March 9 2024 25:00 -> March 10 2024 01: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 ! .

Slide 196

Slide 196 text

CALENDAR + DATECOMPONENTS /// Find the closest matching date to the given date components Calendar.autoupdatingCurrent.date(from dateComponents: DateComponents) Calendar.autoupdatingCurrent.date(byAdding dateComponents: DateComponents, to date: Date)

Slide 197

Slide 197 text

CALENDAR + DATECOMPONENTS /// Find the closest matching date to 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)

Slide 198

Slide 198 text

March 9 2024 17:00 + 8h

Slide 199

Slide 199 text

March 9 2024 17:00 + 8h -> March 10 2024 01:00

Slide 200

Slide 200 text

March 9 2024 17:00 + 8h -> March 10 2024 01:00 March 9 2024 17:00 + 9h

Slide 201

Slide 201 text

March 9 2024 17:00 + 8h -> March 10 2024 01:00 March 9 2024 17:00 + 9h -> March 10 2024 03:00

Slide 202

Slide 202 text

March 9 2024 17:00 + 8h -> March 10 2024 01:00 March 9 2024 17:00 + 9h -> March 10 2024 03:00 March 9 2024 17:00 + 10h

Slide 203

Slide 203 text

March 9 2024 17:00 + 8h -> March 10 2024 01:00 March 9 2024 17:00 + 9h -> March 10 2024 03:00 March 9 2024 17:00 + 10h -> March 10 2024 04:00

Slide 204

Slide 204 text

No content

Slide 205

Slide 205 text

https://xkcd.com/2867/

Slide 206

Slide 206 text

OBLIGATORY SUMMARY SLIDE

Slide 207

Slide 207 text

OBLIGATORY SUMMARY SLIDE > Computers think about dates and time as numeric offsets from a specific point in time

Slide 208

Slide 208 text

OBLIGATORY SUMMARY SLIDE > Computers think about dates and time as numeric offsets from a specific point in time > Humans think about dates in a lot of different ways

Slide 209

Slide 209 text

OBLIGATORY SUMMARY SLIDE > Computers think about dates and time 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

Slide 210

Slide 210 text

OBLIGATORY SUMMARY SLIDE > Computers think about dates and time 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

Slide 211

Slide 211 text

OBLIGATORY SUMMARY SLIDE > Computers think about dates and time 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

Slide 212

Slide 212 text

No content

Slide 213

Slide 213 text

No content

Slide 214

Slide 214 text

No content

Slide 215

Slide 215 text

DONATION LINKS ! https://www.cnio.es/amigos- del-cnio/ ! https:// glioblastomafoundation.org/ get-involved/donate

Slide 216

Slide 216 text

THANK YOU!

Slide 217

Slide 217 text

DATE AND TIME LINKS! > https://developer.apple.com/videos/play/ wwdc2020/10160/ - Apple's guide 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

Slide 218

Slide 218 text

LINKS: TIME EDITION > https://www.esa.int/Applications/ Satellite_navigation/Telling_time_on_the_Moon, the initial proposal the 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

Slide 219

Slide 219 text

LINKS: SERIOUSLY, LISTEN TO DAVE DELONG EDITION > https://yourcalendricalfallacyis.com, a 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