From dac5c41fb00e1ad25c7915f11e102ea763b8aaec Mon Sep 17 00:00:00 2001 From: Seyed Mojtaba Hosseini Zeidabadi Date: Wed, 12 Nov 2025 10:44:47 +0330 Subject: [PATCH 1/4] fix: "update" local variable name --- .../Calendar/Calendar_Gregorian.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift index b7809b9b0..3c8360422 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 From 525def0a6ba02491eeac240e836c7bc08ac1dfa2 Mon Sep 17 00:00:00 2001 From: Seyed Mojtaba Hosseini Zeidabadi Date: Wed, 12 Nov 2025 10:45:19 +0330 Subject: [PATCH 2/4] fix: start"Matching"Weekday local variable name --- .../FoundationEssentials/Calendar/Calendar_Gregorian.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift index 3c8360422..199b7d4c8 100644 --- a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift +++ b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift @@ -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( From 0c3f66aa0e0b591fa917fba2b22747bcba16978f Mon Sep 17 00:00:00 2001 From: Seyed Mojtaba Hosseini Zeidabadi Date: Wed, 12 Nov 2025 10:45:33 +0330 Subject: [PATCH 3/4] docs: fix "ignoring" comment --- Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift index 199b7d4c8..237a378c8 100644 --- a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift +++ b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift @@ -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: From 37251ff167a77315089163a240087b1f605e0d17 Mon Sep 17 00:00:00 2001 From: Seyed Mojtaba Hosseini Zeidabadi Date: Wed, 12 Nov 2025 10:46:19 +0330 Subject: [PATCH 4/4] docs: fix "relevant" comment --- .../Calendar/Calendar_Gregorian.swift | 2 +- .../Calendar/Calendar_Recurrence.swift | 20 +++++++++---------- .../Calendar/DateComponents.swift | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift index 237a378c8..4300a8a85 100644 --- a/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift +++ b/Sources/FoundationEssentials/Calendar/Calendar_Gregorian.swift @@ -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 }