luxon icon indicating copy to clipboard operation
luxon copied to clipboard

Interval.after creates invalid interval when given a DateTime with microseconds and zero duration

Open Woodz opened this issue 3 years ago • 0 comments

Describe the bug Given a DateTime that has a fractional millisecond component, Interval.after will create an invalid interval when given zero duration

To Reproduce

Interval.after(DateTime.fromMillis(123.456), 0)

Actual vs Expected behavior Actual: "The end of an interval must be after its start, but you had start=1970-01-01T07:30:00.123+07:30 and end=1970-01-01T07:30:00.123+07:30" Expected: Valid interval

Desktop (please complete the following information):

  • OS: iOS
  • Browser: Node 14.14.6
  • Luxon version: 1.26.2
  • TS: 4.2

Additional context I am not sure if DateTime should be allowed to be constructed with a fractional millisecond component as it breaks a lot of other things (e.g. rendering as ISO without sub-milliseconds in the error message above)

Woodz avatar Mar 25 '21 02:03 Woodz