`DayOfWeek` ignores `SetWeekStartsAt` value
thijsheijden opened this issue · comments
Hello,
I encountered an issue with the following code:
carbon.CreateFromDate(2023, 8, 14).SetWeekStartsAt(carbon.Sunday).DayOfWeek()
golang version: 1.18
carbon version: 2.2.3
time zone: CET
I expected to get:
2
But I actually get:
1
I would expect the value set by SetWeekStartsAt(carbon.Sunday)
to be taken into account when calculating the day of the week. If the week starts on Sunday, Monday would be the 2nd day of the week.
I can look into the code to attempt to add this feature.
Thanks!
You can try it like this:
carbon.CreateFromDate(2023, 8, 14).SetWeekStartsAt(carbon.Monday).Week() // 0
carbon.CreateFromDate(2023, 8, 14).SetWeekStartsAt(carbon.Sunday).Week() // 1
Ah thank you, the Week
method does what I expected the DayOfWeek
to do.