-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from sebgroup/develop
next release
- Loading branch information
Showing
5 changed files
with
34 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import { isValidDate } from "../isValidDate"; | ||
|
||
/** | ||
* Compare two dates and return true they are the same date ignoring the time | ||
* Compare two dates and return true if the first date is the same as the second date ignoring the time. | ||
* | ||
* @param {Date} a The first date, | ||
* @param {Date} b The second date | ||
* @returns {boolean} True if date are the same | ||
* @returns {boolean} True if date `a` is the same as date `b` | ||
*/ | ||
export function isSameDate(a: Date, b: Date): boolean { | ||
if (!isValidDate(a) || !isValidDate(b)) { | ||
return false; | ||
} else { | ||
return a.toLocaleDateString() === b.toLocaleDateString(); | ||
if (isValidDate(a) && isValidDate(b)) { | ||
a.setHours(0, 0, 0, 0); | ||
b.setHours(0, 0, 0, 0); | ||
return a.valueOf() === b.valueOf(); | ||
} | ||
|
||
return a > b; | ||
} |