-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(date): adding matching at or after a specific date and time oper…
…ator (dateGreaterThanEquals)
- Loading branch information
1 parent
9e5c93d
commit a0e84ca
Showing
4 changed files
with
83 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { dateGreaterThanEquals } from './dateGreaterThanEquals'; | ||
|
||
describe('dateGreaterThanEquals', () => { | ||
it('returns true', () => { | ||
expect( | ||
dateGreaterThanEquals( | ||
new Date('December 17, 1995 03:24:00'), | ||
'December 16, 2000 03:24:00' | ||
) | ||
).toBeTruthy; | ||
expect( | ||
dateGreaterThanEquals( | ||
'December 15, 1994 03:24:00', | ||
new Date('December 15, 1994 03:24:00') | ||
) | ||
).toBeTruthy; | ||
}); | ||
|
||
it('returns false', () => { | ||
expect( | ||
dateGreaterThanEquals( | ||
new Date('December 17, 1995 03:24:00'), | ||
'December 17, 1995 03:25:00' | ||
) | ||
).toBeFalsy; | ||
expect( | ||
dateGreaterThanEquals( | ||
new Date('December 15, 1995 03:24:00'), | ||
new Date('December 16, 1995 03:24:00') | ||
) | ||
).toBeFalsy; | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DateType, convertDate } from './convertDate'; | ||
|
||
/** | ||
* Matching at or after a specific date and time | ||
* | ||
* @since 4.11.0 | ||
* @category Date | ||
* @param {Date} data The value to be compared. | ||
* @param {Date} expected The expected value. | ||
* @returns {boolean} Returns `true` if `value` is after than or equals `expected value`. | ||
* @example | ||
* ```javascript | ||
* dateGreaterThanEquals('December 17, 1994 03:24:00', 'December 16, 1994 03:24:00') | ||
* // => true | ||
* | ||
* dateGreaterThanEquals('December 15, 2000 03:24:00', 'December 15, 2000 03:25:00') | ||
* // => false | ||
* ``` | ||
*/ | ||
export function dateGreaterThanEquals( | ||
data: DateType, | ||
expected: DateType | ||
): boolean { | ||
const convertedData = convertDate(data); | ||
const convertedExpectation = convertDate(expected); | ||
return convertedData >= convertedExpectation; | ||
} |
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