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
Describe the bug
The Interval documentation states that
An Interval object represents a half-open interval of time
To me this means that the interval includes the starting point, but not the end point. This is confirmed by checking interval.contains(interval.end), which always returns false. However Interval#count also counts the endpoint.
To Reproduce
const{Interval, DateTime}=require('luxon');conststartDate=DateTime.fromISO("2022-10-01T00:00:00.000+02:00");constinterval=Interval.after(startDate,{days: 2});console.log(interval.contains(interval.end));// as expected this is falseconsole.log(interval.count('days'));// this reports 3, but the interval only contains 2 calendar days (1st and 2nd)console.log(interval.length('hours'));// as expected this reports exactly 48, because the first millisecond of the 3rd is not included
Actual vs Expected behavior Interval#count should not count the interval's endpoint.
Desktop (please complete the following information):
OS: Linux Mint
Browser: Chrome 106, also happens on Node 14
Luxon version: 3.0.4
Your timezone: Europe/Berlin
Additional context
Looking at the code for count, it unconditionally adds 1 to the result of diffing start and end. This addition must only be done if end is actually different from end.startOf(unit).
The text was updated successfully, but these errors were encountered:
Describe the bug
The Interval documentation states that
To me this means that the interval includes the starting point, but not the end point. This is confirmed by checking
interval.contains(interval.end)
, which always returns false. HoweverInterval#count
also counts the endpoint.To Reproduce
See here: https://runkit.com/embed/xxwq2ofg22di
Actual vs Expected behavior
Interval#count
should not count the interval's endpoint.Desktop (please complete the following information):
Additional context
Looking at the code for
count
, it unconditionally adds 1 to the result of diffing start and end. This addition must only be done ifend
is actually different fromend.startOf(unit)
.The text was updated successfully, but these errors were encountered: