Skip to content

Commit

Permalink
Simplify the .startOfWeek accessor
Browse files Browse the repository at this point in the history
Fixes issue #71
  • Loading branch information
davedelong committed Apr 6, 2024
1 parent 1a3b79f commit 1798d75
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions Sources/Time/6-Adjustments/Fixed+SafeAdjustment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,7 @@ extension Fixed where Granularity: StandardUnit & LTOEDay {

/// Adjust the date to the beginning of the calendar's week.
public var startOfWeek: Self {
var s = self
let targetWeekday = region.calendar.firstWeekday

// Github issue #71 tracks improving this
while s.dayOfWeek != targetWeekday {
s = s.previousDay
}
return s
return self.fixedWeek.first()
}

/// Create a new `Fixed` value by moving forward one day.
Expand Down

0 comments on commit 1798d75

Please sign in to comment.