project files added
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
||||
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.
|
||||
|
||||
import { isValid } from 'date-fns'
|
||||
export default isValid
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
import toDate from '../toDate/index.js';
|
||||
/**
|
||||
* @name isValid
|
||||
* @category Common Helpers
|
||||
* @summary Is the given date valid?
|
||||
*
|
||||
* @description
|
||||
* Returns false if argument is Invalid Date and true otherwise.
|
||||
* Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
|
||||
* Invalid Date is a Date, whose time value is NaN.
|
||||
*
|
||||
* Time value of Date: http://es5.github.io/#x15.9.1.1
|
||||
*
|
||||
* ### v2.0.0 breaking changes:
|
||||
*
|
||||
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
||||
*
|
||||
* - Now `isValid` doesn't throw an exception
|
||||
* if the first argument is not an instance of Date.
|
||||
* Instead, argument is converted beforehand using `toDate`.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* | `isValid` argument | Before v2.0.0 | v2.0.0 onward |
|
||||
* |---------------------------|---------------|---------------|
|
||||
* | `new Date()` | `true` | `true` |
|
||||
* | `new Date('2016-01-01')` | `true` | `true` |
|
||||
* | `new Date('')` | `false` | `false` |
|
||||
* | `new Date(1488370835081)` | `true` | `true` |
|
||||
* | `new Date(NaN)` | `false` | `false` |
|
||||
* | `'2016-01-01'` | `TypeError` | `false` |
|
||||
* | `''` | `TypeError` | `false` |
|
||||
* | `1488370835081` | `TypeError` | `true` |
|
||||
* | `NaN` | `TypeError` | `false` |
|
||||
*
|
||||
* We introduce this change to make *date-fns* consistent with ECMAScript behavior
|
||||
* that try to coerce arguments to the expected type
|
||||
* (which is also the case with other *date-fns* functions).
|
||||
*
|
||||
* @param {*} date - the date to check
|
||||
* @returns {Boolean} the date is valid
|
||||
* @throws {TypeError} 1 argument required
|
||||
*
|
||||
* @example
|
||||
* // For the valid date:
|
||||
* var result = isValid(new Date(2014, 1, 31))
|
||||
* //=> true
|
||||
*
|
||||
* @example
|
||||
* // For the value, convertable into a date:
|
||||
* var result = isValid(1393804800000)
|
||||
* //=> true
|
||||
*
|
||||
* @example
|
||||
* // For the invalid date:
|
||||
* var result = isValid(new Date(''))
|
||||
* //=> false
|
||||
*/
|
||||
|
||||
export default function isValid(dirtyDate) {
|
||||
if (arguments.length < 1) {
|
||||
throw new TypeError('1 argument required, but only ' + arguments.length + ' present');
|
||||
}
|
||||
|
||||
var date = toDate(dirtyDate);
|
||||
return !isNaN(date);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// @flow
|
||||
// This file is generated automatically by `scripts/build/typings.js`. Please, don't change it.
|
||||
|
||||
export type Interval = {
|
||||
start: Date | number,
|
||||
end: Date | number
|
||||
}
|
||||
|
||||
export type Locale = {
|
||||
formatDistance: (...args: Array<any>) => any,
|
||||
formatRelative: (...args: Array<any>) => any,
|
||||
localize: {
|
||||
ordinalNumber: (...args: Array<any>) => any,
|
||||
era: (...args: Array<any>) => any,
|
||||
quarter: (...args: Array<any>) => any,
|
||||
month: (...args: Array<any>) => any,
|
||||
day: (...args: Array<any>) => any,
|
||||
dayPeriod: (...args: Array<any>) => any
|
||||
},
|
||||
formatLong: Object,
|
||||
date: (...args: Array<any>) => any,
|
||||
time: (...args: Array<any>) => any,
|
||||
dateTime: (...args: Array<any>) => any,
|
||||
match: {
|
||||
ordinalNumber: (...args: Array<any>) => any,
|
||||
era: (...args: Array<any>) => any,
|
||||
quarter: (...args: Array<any>) => any,
|
||||
month: (...args: Array<any>) => any,
|
||||
day: (...args: Array<any>) => any,
|
||||
dayPeriod: (...args: Array<any>) => any
|
||||
},
|
||||
options?: {
|
||||
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6,
|
||||
firstWeekContainsDate?: 1 | 2 | 3 | 4 | 5 | 6 | 7
|
||||
}
|
||||
}
|
||||
|
||||
declare module.exports: (date: any) => boolean
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"sideEffects": false,
|
||||
"typings": "../../typings.d.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user