You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(note that the number of hours returned by the first call will vary depending on the current system time, e.g. calling the function at 12:00 should instead result in {:ok, "in 12 hours"})
Description of issue
I would expect the relative date of today + 1 day to result in tomorrow, but instead it is today + 2 days that gives tomorrow.
The reason for this is due to Timex.Format.DateTime.Formatters.Relative.lformat/3 which calls Timex.to_naive_datetime/1 on the passed date. The returned value of Timex.to_naive_datetime/1 for a Date-struct is the same date as the Date-struct, but with a time of 00:00:00. This means that a call to Timex.Format.DateTime.Formatters.Relative.lformat/3 when the passed date is a Date-struct in the future, in x days will always be off by 1 day.
I haven't found any examples of past days having incorrect offsets, though! 👍
The text was updated successfully, but these errors were encountered:
HansGlimmerfors
changed the title
Relative formatting of future Date-structs are off by 1 day
Relative formatting of future Date-structs is off by 1 day
Dec 25, 2024
Steps to reproduce
(note that the number of hours returned by the first call will vary depending on the current system time, e.g. calling the function at 12:00 should instead result in
{:ok, "in 12 hours"}
)Description of issue
I would expect the relative date of
today + 1 day
to result intomorrow
, but instead it istoday + 2 days
that givestomorrow
.The reason for this is due to
Timex.Format.DateTime.Formatters.Relative.lformat/3
which callsTimex.to_naive_datetime/1
on the passed date. The returned value ofTimex.to_naive_datetime/1
for aDate
-struct is the same date as theDate
-struct, but with a time of 00:00:00. This means that a call toTimex.Format.DateTime.Formatters.Relative.lformat/3
when the passed date is aDate
-struct in the future,in x days
will always be off by 1 day.I haven't found any examples of past days having incorrect offsets, though! 👍
The text was updated successfully, but these errors were encountered: