moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.32k stars 730 forks source link

Interval.splitBy for seconds #1559

Closed RubayloDev closed 6 months ago

RubayloDev commented 9 months ago

Interval.fromDateTimes(day.set({ day: firstDay, 'hour': 0, 'minute':0 }), day.set({ day: firstDay, 'hour': 2, 'minute':0, 'seconds':30 })).splitBy('hour') return 2 elements

Interval.fromDateTimes(day.set({ day: firstDay, 'hour': 0, 'minute':0 }), day.set({ day: firstDay, 'hour': 2, 'minute':1, 'seconds':0 })).splitBy('hour') return 3 elements

Expected result. 3 elements in both cases

diesieben07 commented 9 months ago

The code you have posted doesn't actually work, splitBy expects a Duration, not a string. Please also post the values for day and firstDay as well as your time zone. I suspect you are observing the effects of DST.