Skip to content

Commit 598f6a1

Browse files
committed
Fix: StartOfWeek and EndOfWeek methods change original Carbon instance Unexpectedly #304
1 parent a929522 commit 598f6a1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

boundary.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *Carbon) StartOfWeek() *Carbon {
9999
if dayOfWeek == weekStartsAt {
100100
return c.StartOfDay()
101101
}
102-
return c.SubDays(int(DaysPerWeek+dayOfWeek-weekStartsAt) % DaysPerWeek).StartOfDay()
102+
return c.Copy().SubDays(int(DaysPerWeek+dayOfWeek-weekStartsAt) % DaysPerWeek).StartOfDay()
103103
}
104104

105105
// EndOfWeek returns a Carbon instance for end of the week.
@@ -111,7 +111,7 @@ func (c *Carbon) EndOfWeek() *Carbon {
111111
if dayOfWeek == weekEndsAt {
112112
return c.EndOfDay()
113113
}
114-
return c.AddDays(int(DaysPerWeek-dayOfWeek+weekEndsAt) % DaysPerWeek).EndOfDay()
114+
return c.Copy().AddDays(int(DaysPerWeek-dayOfWeek+weekEndsAt) % DaysPerWeek).EndOfDay()
115115
}
116116

117117
// StartOfDay returns a Carbon instance for start of the day.

0 commit comments

Comments
 (0)