Skip to content

Conversation

@syukronrm
Copy link

Summary of changes

Fixes issue #616

Currently week_of_month/3 relying on iso_week/3. But at certain cases iso_week/3 return different year than the year input, it may return the previous or the next year.

Example case for returning week on the previous year.

iex(1)> Timex.iso_week(2021, 1, 1)
{2020, 53}

Thus, it leads to:

iex(3)> Timex.week_of_month(2021, 1, 10)
-51 # should be 1

This is the case for returning the next year.

iex(6)> Timex.iso_week(2019, 12, 31)     
{2020, 1}

Leads to:

iex(7)> Timex.week_of_month(2019, 12, 31)
-46 # should be 6

Checklist

  • Tests were added or updated to cover changes
  • Commits were squashed into a single coherent commit

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 72.141% when pulling eaa2965 on syukronrm:fix-negative-week-of-month into 45424fa on bitwalker:master.

@syukronrm
Copy link
Author

syukronrm commented Oct 2, 2020

I believe this also cover PR #568.

@bitwalker
Copy link
Owner

The behaviour you specified here is expected - that is how ISO weeks are defined, they don't necessarily perfectly overlap with calendar weeks/year.

@bitwalker bitwalker closed this Dec 25, 2020
@bitwalker bitwalker reopened this Dec 25, 2020
@bitwalker
Copy link
Owner

Sorry, I'm dumb - missed that this wasn't changing the ISO week behavior.

@bitwalker bitwalker merged commit 078e50d into bitwalker:master Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants