Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isBetween() with inclusive flags returns true for invalid date #4416

Closed
mzbyszynski opened this issue Jan 26, 2018 · 1 comment · Fixed by #4417
Closed

isBetween() with inclusive flags returns true for invalid date #4416

mzbyszynski opened this issue Jan 26, 2018 · 1 comment · Fixed by #4417
Labels

Comments

@mzbyszynski
Copy link

Description of the Issue and Steps to Reproduce:
isBetween() returns true when passed an invalid date with both inclusive flags set:

> const inval = new Date('foo')
undefined
> moment(inval)
moment.invalid(/* Invalid Date */)
> moment(inval).isBetween('2010-01','2011-01')
false
> moment(inval).isBetween('2010-01','2011-01', null)
false
> moment(inval).isBetween('2010-01','2011-01', null, '()')
false
> moment(inval).isBetween('2010-01','2011-01', null, '[]')
true

Environment:
node 8.9.1 on Ubuntu 16.04 LTS

Other information that may be helpful:

If you are reporting an issue, please run the following code in the environment you are using and include the output:

console.log( (new Date()).toString())
console.log((new Date()).toLocaleString())
console.log( (new Date()).getTimezoneOffset())
console.log( navigator.userAgent)
console.log(moment.version)

output:

root@42796179bd1d:/work# node -v
v8.9.1
root@42796179bd1d:/work# node
> const moment = require('moment')
undefined
> console.log( (new Date()).toString())
Fri Jan 26 2018 19:55:20 GMT+0000 (UTC)
undefined
> console.log((new Date()).toLocaleString())
2018-1-26 19:55:20
undefined
> console.log( (new Date()).getTimezoneOffset())
0
undefined
> console.log( navigator.userAgent)
ReferenceError: navigator is not defined
    at repl:1:14
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)
    at emitOne (events.js:121:20)
    at REPLServer.emit (events.js:211:7)
    at REPLServer.Interface._onLine (readline.js:282:10)
    at REPLServer.Interface._line (readline.js:631:8)
> console.log(moment.version)
2.20.1
@ichernev
Copy link
Contributor

@mzbyszynski thank you for reporting this. Close in favor of #4417

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants