Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DayOfWeek ignores SetWeekStartsAt value #179

Closed
thijsheijden opened this issue Aug 14, 2023 · 2 comments
Closed

DayOfWeek ignores SetWeekStartsAt value #179

thijsheijden opened this issue Aug 14, 2023 · 2 comments
Labels
Bug Report a reproducible bug or regression

Comments

@thijsheijden
Copy link

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!

@thijsheijden thijsheijden added the Bug Report a reproducible bug or regression label Aug 14, 2023
@gouguoyin
Copy link
Collaborator

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

@thijsheijden
Copy link
Author

Ah thank you, the Week method does what I expected the DayOfWeek to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report a reproducible bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants