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

Timex.format/2 Wrong week number when using Wsun or %U #742

Open
dmarkow opened this issue May 1, 2023 · 1 comment
Open

Timex.format/2 Wrong week number when using Wsun or %U #742

dmarkow opened this issue May 1, 2023 · 1 comment

Comments

@dmarkow
Copy link

dmarkow commented May 1, 2023

In the example below, getting a week number using Monday as the start of the week works correctly: today, May 1st, is a new week. But if I try it with the week starting on a Sunday, it's actually identifying Saturday April 29th as the start of this week, when it should be April 30th. Here is the output for the last 4 days, Friday through Monday:

iex(54)> [~D(2023-04-28), ~D(2023-04-29), ~D(2023-04-30), ~D(2023-05-01)] |> Enum.map(&Timex.format!(&1, "%W", :strftime))
["17", "17", "17", "18"]
iex(55)> [~D(2023-04-28), ~D(2023-04-29), ~D(2023-04-30), ~D(2023-05-01)] |> Enum.map(&Timex.format!(&1, "%U", :strftime))
["16", "17", "17", "17"]
iex(56)> [~D(2023-04-28), ~D(2023-04-29), ~D(2023-04-30), ~D(2023-05-01)] |> Enum.map(&Timex.format!(&1, "{Wmon}"))
["17", "17", "17", "18"]
iex(57)> [~D(2023-04-28), ~D(2023-04-29), ~D(2023-04-30), ~D(2023-05-01)] |> Enum.map(&Timex.format!(&1, "{Wsun}"))
["16", "17", "17", "17"]
@dmarkow
Copy link
Author

dmarkow commented May 1, 2023

Looks like this changed in 3.7.2.

Timex 3.7.1 has correct output:

iex(1)> [~D(2023-04-28), ~D(2023-04-29), ~D(2023-04-30), ~D(2023-05-01)] |> Enum.map(&Timex.format!(&1, "{Wsun}"))
["17", "17", "18", "18"]

Timex 3.7.2 has the wrong output:

iex(1)> [~D(2023-04-28), ~D(2023-04-29), ~D(2023-04-30), ~D(2023-05-01)] |> Enum.map(&Timex.format!(&1, "{Wsun}"))
["16", "17", "17", "17"]

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

No branches or pull requests

1 participant