diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift index b7809b9b0..4300a8a85 100644 --- a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift +++ b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift @@ -846,15 +846,15 @@ internal final class _CalendarGregorian: _CalendarProtocol, @unchecked Sendable if startAtUnit == .day || startAtUnit == .weekday || startAtUnit == .weekdayOrdinal { let targetDay = dateComponent(.day, from: updatedDate) var currentDay = targetDay - var udate = updatedDate + var update = updatedDate var prev: Date repeat { - prev = udate - udate = try self.add(.second, to: prev, amount: -1, inTimeZone: timeZone) - guard udate < prev else { - throw GregorianCalendarError.notAdvancing(udate, prev) + prev = update + update = try self.add(.second, to: prev, amount: -1, inTimeZone: timeZone) + guard update < prev else { + throw GregorianCalendarError.notAdvancing(update, prev) } - currentDay = dateComponent(.day, from: udate) + currentDay = dateComponent(.day, from: update) } while targetDay == currentDay start = prev @@ -989,13 +989,13 @@ internal final class _CalendarGregorian: _CalendarProtocol, @unchecked Sendable case .weekOfYear, .weekOfMonth: /* kCFCalendarUnitWeek_Deprecated */ guard var start = start(of: .era, at: date) else { return nil } - var (startMatchinWeekday, daysAdded) = try dateAfterDateWithTargetDoW(start, firstWeekday) + var (startMatchingWeekday, daysAdded) = try dateAfterDateWithTargetDoW(start, firstWeekday) start += Double(daysAdded) * 86400.0 if minimumDaysInFirstWeek <= daysAdded { // previous week chunk was big enough, count it - startMatchinWeekday -= 7 * 86400.0 + startMatchingWeekday -= 7 * 86400.0 start -= 7 * 86400.0 } var week = Int(floor( @@ -2272,7 +2272,7 @@ internal final class _CalendarGregorian: _CalendarProtocol, @unchecked Sendable switch field { case .era: - // We've been ignorning era historically. Do the same for compatibility reason. + // We've been ignoring era historically. Do the same for compatibility reason. return date case .yearForWeekOfYear: @@ -2395,7 +2395,7 @@ internal final class _CalendarGregorian: _CalendarProtocol, @unchecked Sendable let newOffset = timeZone.secondsFromGMT(for: newDateInWholeSecond) let prevOffset = timeZone.secondsFromGMT(for: date) - // No need for normal gmt-offset adjustment because the revelant bits are handled above individually + // No need for normal gmt-offset adjustment because the relevant bits are handled above individually // We do have to adjust DST offset when the new date crosses DST boundary, such as adding an hour to dst transitioning day if newOffset != prevOffset { newDateInWholeSecond = newDateInWholeSecond + Double(prevOffset - newOffset) diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Recurrence.swift b/Sources/FoundationEssentials/Calendar/Calendar_Recurrence.swift index dd8740236..889b98311 100644 --- a/Sources/FoundationEssentials/Calendar/Calendar_Recurrence.swift +++ b/Sources/FoundationEssentials/Calendar/Calendar_Recurrence.swift @@ -12,7 +12,7 @@ // // Recurrence enumeration // -// This file implements enumerating occurences according to a recurrence rule as +// This file implements enumerating occurrences according to a recurrence rule as // specified in RFC5545 and RFC7529 extension Calendar.RecurrenceRule.Frequency { @@ -623,11 +623,11 @@ extension Calendar { /// - parent: .year if the frequency is yearly, otherwise .month /// - anchor: a date around which to perform the expansion /// - Returns: array of `DateComponents`, which can be used to enumerate all - /// weekdays of intereset, or to filter a list of dates + /// weekdays of interest, or to filter a list of dates func _weekdayComponents(for weekdays: [Calendar.RecurrenceRule.Weekday], in parent: Calendar.Component, anchor: Date) -> [DateComponents]? { - /// Map of weekdays to which occurences of the weekday we are interested + /// Map of weekdays to which occurrences of the weekday we are interested /// in. `1` is the first such weekday in the interval, `-1` is the last. /// An empty array indicates that any weekday is valid var map: [Locale.Weekday: [Int]] = [:] @@ -650,7 +650,7 @@ extension Calendar { // necessarily occur in the first week of the month. /// The component where we set the week number, if we are targeting only - /// a particular occurence of a weekday + /// a particular occurrence of a weekday let weekComponent: Calendar.Component = if parent == .month { .weekOfMonth } else { @@ -671,9 +671,9 @@ extension Calendar { // few seconds can give us the last day in the interval lazy var lastWeekday = component(.weekday, from: interval.end.addingTimeInterval(-0.1)) - for (weekday, occurences) in map { + for (weekday, occurrences) in map { let weekdayIdx = weekday.icuIndex - if occurences == [] { + if occurrences == [] { var components = DateComponents() components.setValue(nil, for: weekComponent) components.weekday = weekdayIdx @@ -681,12 +681,12 @@ extension Calendar { } else { lazy var firstWeek = weekRange.lowerBound + (weekdayIdx < firstWeekday ? 1 : 0) lazy var lastWeek = weekRange.upperBound - (weekdayIdx > lastWeekday ? 1 : 0) - for occurence in occurences { + for occurrence in occurrences { var components = DateComponents() - if occurence > 0 { - components.setValue(firstWeek - 1 + occurence, for: weekComponent) + if occurrence > 0 { + components.setValue(firstWeek - 1 + occurrence, for: weekComponent) } else { - components.setValue(lastWeek + occurence, for: weekComponent) + components.setValue(lastWeek + occurrence, for: weekComponent) } components.weekday = weekdayIdx result.append(components) diff --git a/Sources/FoundationEssentials/Calendar/DateComponents.swift b/Sources/FoundationEssentials/Calendar/DateComponents.swift index 1177a7c2b..014359bee 100644 --- a/Sources/FoundationEssentials/Calendar/DateComponents.swift +++ b/Sources/FoundationEssentials/Calendar/DateComponents.swift @@ -448,7 +448,7 @@ public struct DateComponents : Hashable, Equatable, Sendable { // MARK: - - /// Returns a new `DateComponents` where the subset of fields that can be scaled have been mulitplied by `value`. + /// Returns a new `DateComponents` where the subset of fields that can be scaled have been multiplied by `value`. internal func scaled(by value: Int) -> DateComponents { var dc = self if let era = _era { dc.era = era * value }