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
Using .add() or .subtract() – possibly other methods – passing a new Date() or moment object as the first argument creates an invalid date. This is inconsistent with the behavior in 2.24.0 and inconsistent with other invalid inputs I tested.
Expected behavior
A clear and concise description of what you expected to happen.
The behavior of .add() and .subtract() should be consistent for invalid data.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
OS: macOS 13.2.1
Browser Chrome
Version 110.0.5481.177
Also tested on Node 16.16.0 (see screenshots)
Moment-specific environment
The time zone setting of the machine the code is running on: EST
The time and date at which the code was run: 2023-02-28T16:45:00-05:00
Other libraries in use: none
Please run the following code in your environment and include the output:
'Tue Feb 28 2023 16:50:21 GMT-0500 (Eastern Standard Time)'
'2/28/2023, 4:50:21 PM'
300
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) runjs/2.7.5 Chrome/106.0.5249.168 Electron/21.2.2 Safari/537.36'
'2.29.4'
Additional context
This is not a serious concern for us, but it is a change that didn't appear to be documented, though I may have missed it. We discovered this as an invalid moment was provided to a datepicker and "broke" .isBefore() and .isAfter() checks for disabling out-of-range days.
The text was updated successfully, but these errors were encountered:
Describe the bug
Using .add() or .subtract() – possibly other methods – passing a
new Date()
ormoment
object as the first argument creates an invalid date. This is inconsistent with the behavior in 2.24.0 and inconsistent with other invalid inputs I tested.To Reproduce
Steps to reproduce the behavior:
moment('2023-01-01').add(new Date(), 'days').format()
produces-0NaN--NaN--NaNT-NaN:-NaN:-NaN+00:00
moment('2023-01-01').add({}, 'days').format()
produces2023-01-01T00:00:00-05:00
(for EST)Expected behavior
A clear and concise description of what you expected to happen.
The behavior of
.add()
and.subtract()
should be consistent for invalid data.Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Also tested on Node 16.16.0 (see screenshots)
Moment-specific environment
Please run the following code in your environment and include the output:
In RunJS:
Additional context
This is not a serious concern for us, but it is a change that didn't appear to be documented, though I may have missed it. We discovered this as an invalid moment was provided to a datepicker and "broke"
.isBefore()
and.isAfter()
checks for disabling out-of-range days.The text was updated successfully, but these errors were encountered: