iamkun / iamkun/dayjs

isBefore() produces strange result when provided any one or both of the parameter as undefined.

Open
#2,341 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When we pass `undefined` as parameter in `dayjs().isBefore` then it sometimes it returns `true` and sometimes it returns `false`.
This breaks the code someone uses in condition;

*Steps to reproduce*
Step 1: Open chrome or any editor which has dayjs
Step 2: Log this piece of code 7-8 `dayjs(undefined).isBefore(undefined)` you might see different result.

**Screenshots**

Screenshot 2023-06-18 at 12 55 48 PM

A Clear & Better :
Screenshot 2023-06-18 at 12 58 26 PM

**Expected behavior**
Expected behaviour should be like if you pass both as undefined then it should return false every time or a single boolean (true or false any one them) OR it should be handled and thrown appropriate error.

**Information**
- Day.js Version [v1.11.8]
- OS: [macOS]
- Browser [chrome]
- Time zone: [e.g. GTT +5:30 IST (Asia/ Kolkata Time Zone)]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.