timex
timex copied to clipboard
Set correct day when year or month is changed too
Summary of changes
- when you call
Timex.set/2function from date which has less days than new month it should apply month or year changes before day changes so validation will be correct. So options have to be in exact order: year, month, day - added alias for Helpers module
Example before this fix:
Timex.now() |> Timex.set(day: 31, month: 5)
~U[2021-05-30 17:49:07.917681Z]
Timex.now() |> Timex.set(month: 5, day: 31)
~U[2021-05-31 17:49:10.264841Z]
There you can see correct date is only when I change order of options.
Checklist
- [ ] New functions have typespecs, changed functions were updated
- [ ] Same for documentation, including moduledocs
- [x] Tests were added or updated to cover changes
- [x] Commits were squashed into a single coherent commit
- [ ] Notes added to CHANGELOG file which describe changes at a high-level
I did some cosmetic changes so there 3 commits. In case it will be ok, I can make new PR with one commit.
I added your suggestion code, all tests passed. It looks now better. Thanks for good suggestion.
Sorry but I don't understand what you want with this:
Could you also rebase/squash your commits? You don't have to break up the cosmetic changes at this point (please do in the future though)
I updated my main branch and now it's code base same as in your master, plus my changes. I don't like doing hard reset and creating one commit. Because it can be done when this PR will be merged. Because we would lost history about the changes and I'm not sure about this PR, maybe it will just update PR or I would have to create new one after reset and squash commits. Maybe I'm wrong so sorry and please give me a advice.

Any chance this can be merged?