bitwalker / bitwalker/timex

Timex.format seems off at the end of the month

Open
#732 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elixir
Stars
1.8k
Forks
407
PR merge metrics
No merged PRs in 30d

Description

### Steps to reproduce

```
iex> in_5_months = Timex.shift(Timex.now(), months: 5)
~U[2023-06-30 07:51:27.003055Z]
iex> Timex.format!(in_5_months, "{relative}", :relative)
"in 4 months"
```

### Description of issue

- Timex.format seems to miss a month - the result should be "in 5 months", instead of "in 4 months". The output of Timex.shift looks good.
- It seems the error is only occuring starting recently, it was fine before.
- At first I thought it was because due to me testing on the 31st. But apparently the issue is not related to the date. I guess it depends if Timex.format does some rounding? Otherwise 5 months - a few secons is already 4 months. It works fine if I add another hour. I'm just curious why it worked before.

Could this be related to this issue? https://github.com/bitwalker/timex/issues/535

I hope I didn't miss any other open issue related to this. Thank you for the great work!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported Timex.shift and Timex.format! calls using the "{relative}" formatter and :relative option, then inspect the relative-formatting entry point. Compare the result near month boundaries and with an added hour. Done means the example reports the expected month count and regression coverage demonstrates the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.