Expected behaviour
I would expectInterval.hasSame to return
false for 12:15 UTC+2 and 11:15 UTC+1 (same unix timestamp, same UTC hours, different local hours)
because that should be the same case as the first example above.
Actual behaviour
Instead Interval.hasSame always returns true if the interval isEmpty (-> same unix timestamps) even if different timezones would result in different local unit values.
Interval.hasSame
ignores timezones unless the interval is empty.Baseline
Interval.hasSame
(expectedly) returnsfalse
for12:15 UTC+2
and11:30 UTC+1
(different unix timestamp, same UTC hours, different local hours)true
for12:15 UTC+2
and12:30 UTC+2
(different unix timestamp, different UTC hours, same local hours)because the local hours are matching.
That is because
Interval.hasSame
internally usesDateTime.hasSame
which ignores timezones when comparing unit values. https://github.com/moment/luxon/blob/d30908f973359e8c4127535858e48599d7e0b7c0/src/datetime.js#L1950Expected behaviour I would expect
Interval.hasSame
to returnfalse
for12:15 UTC+2
and11:15 UTC+1
(same unix timestamp, same UTC hours, different local hours)because that should be the same case as the first example above.
Actual behaviour Instead
Interval.hasSame
always returnstrue
if the intervalisEmpty
(-> same unix timestamps) even if different timezones would result in different local unit values.Analysis This bug (?) seems to have been introduced in https://github.com/moment/luxon/issues/709 by returning
true
early in case the intervalisEmpty
. https://github.com/moment/luxon/blob/33f79577a16f56629ddf9c1f1034259da7222d9c/src/interval.js#L251-L253Example code
P.S.: Thank's for providing this lib!