Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Info.monthsFormat lists all the months', () => {
expect(Info.monthsFormat('long', 'en')).toEqual(
['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
);
//this passes, but is wrong. These are the same as the standalone values
//t.deepEqual(
// Info.monthsFormat('long', 'ru'),
// ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']);
expect(Info.monthsFormat('short', 'en')).toEqual(
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
);
expect(Info.monthsFormat('numeric', 'en')).toEqual(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']);
});
it('Info.monthsFormat lists all the months', () => {
expect(Info.monthsFormat('long', 'en')).toEqual(
['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
);
//this passes, but is wrong. These are the same as the standalone values
//t.deepEqual(
// Info.monthsFormat('long', 'ru'),
// ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']);
expect(Info.monthsFormat('short', 'en')).toEqual(
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
);
expect(Info.monthsFormat('numeric', 'en')).toEqual(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']);
});
it('Info.monthsFormat lists all the months', () => {
expect(Info.monthsFormat('long', 'en')).toEqual(
['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
);
//this passes, but is wrong. These are the same as the standalone values
//t.deepEqual(
// Info.monthsFormat('long', 'ru'),
// ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря']);
expect(Info.monthsFormat('short', 'en')).toEqual(
['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
);
expect(Info.monthsFormat('numeric', 'en')).toEqual(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']);
});
const end = DateTime.fromISO('2017-03-13');
const start = DateTime.fromISO('2017-02-13');
const diffInMonths = end.diff(start, 'months');
diffInMonths.toObject().months; // $ExpectType number | undefined
const diff = end.diff(start);
diff.toObject().milliseconds; // $ExpectType number | undefined
end.diff(start, ['months', 'days']).months; // $ExpectType number
end.diffNow(['months', 'days']); // $ExpectType Duration
dur.as('days'); // $ExpectType number
dur.shiftTo('days').toObject().days; // $ExpectType number | undefined
dur.shiftTo('week', 'hours').toObject().weeks; // $ExpectType number | undefined
DateTime.local().plus(dur.shiftTo('milliseconds')).year; // $ExpectType number
Duration.fromISO('PY23', { conversionAccuracy: 'longterm' }); // $ExpectType Duration
end.diff(start, 'hours', { conversionAccuracy: 'longterm' }); // $ExpectType Duration
end.diff(start, ['months', 'days', 'hours']); // $ExpectType Duration
dur.reconfigure({ conversionAccuracy: 'longterm' }); // $ExpectType Duration
start.until(end); // $ExpectType Interval
i.toDuration(['years', 'months', 'days']); // $ExpectType Duration
/* Sample Zone Implementation */
class SampleZone extends Zone {
readonly isValid = false;
readonly name = 'Sample';
readonly type = 'Example';
readonly universal = true;
});
var date: DateTime = DateTime.invalid("test");
// $ExpectError
DateTime.invalid();
// Flow 0.40 - 0.45 allows these but they're incorrect...bug!
// DateTime.max();
// DateTime.min();
var date = DateTime.max(DateTime.local(), DateTime.utc(), DateTime.utc());
var date = DateTime.min(DateTime.local(), DateTime.utc(), DateTime.utc());
// $ExpectError
var date = DateTime.max(DateTime.local(), null, DateTime.utc());
// $ExpectError
var date = DateTime.min(DateTime.local(), null, DateTime.utc());
(date.day: number);
(date.daysInMonth: number);
(date.daysInYear: number);
(date.hour: number);
(date.invalidReason: ?string);
(date.isInDST: boolean);
(date.isInLeapYear: boolean);
(date.isOffsetFixed: boolean);
(date.isValid: boolean);
(date.locale: string);
(date.millisecond: number);
(date.minute: number);
(date.month: number);
(date.monthLong: string);
(date.monthShort: string);
});
var date: DateTime = DateTime.invalid("test");
// $ExpectError
DateTime.invalid();
// Flow 0.40 - 0.45 allows these but they're incorrect...bug!
// DateTime.max();
// DateTime.min();
var date = DateTime.max(DateTime.local(), DateTime.utc(), DateTime.utc());
var date = DateTime.min(DateTime.local(), DateTime.utc(), DateTime.utc());
// $ExpectError
var date = DateTime.max(DateTime.local(), null, DateTime.utc());
// $ExpectError
var date = DateTime.min(DateTime.local(), null, DateTime.utc());
(date.day: number);
(date.daysInMonth: number);
(date.daysInYear: number);
(date.hour: number);
(date.invalidReason: ?string);
(date.isInDST: boolean);
(date.isInLeapYear: boolean);
(date.isOffsetFixed: boolean);
(date.isValid: boolean);
(date.locale: string);
(date.millisecond: number);
(date.minute: number);
(date.month: number);
(date.monthLong: string);
(date.monthShort: string);
(dur.toObject().milliseconds: ?number);
(dur.toObject({ includeConfig: true }).locale: string);
(dur.toObject({ includeConfig: true }).numberingSystem: ?string);
(dur.toObject({ includeConfig: true }).conversionAccuracy: ?string);
// $ExpectError
dur.toObject({ includeConfig: false }).locale;
// $ExpectError
dur.toObject({ includeConfig: false }).numberingSystem;
// $ExpectError
dur.toObject({ includeConfig: false }).conversionAccuracy;
(dur.toString(): string);
(Interval.after(DateTime.utc(), Duration.fromObject({ year: 1 })): Interval);
(Interval.after(DateTime.utc(), { year: 1 }): Interval);
(Interval.after(DateTime.utc(), 1231234): Interval);
(Interval.after(
{ year: 2017, month: 1 },
Duration.fromObject({ year: 1 })
): Interval);
(Interval.after({ year: 2017, month: 1 }, { year: 1 }): Interval);
(Interval.after({ year: 2017, month: 1 }, 123123): Interval);
// $ExpectError
(Interval.after({ year: 2017, month: 1, foo: "bar" }, { year: 1 }): Interval);
// $ExpectError
(Interval.after({ year: 2017, month: 1 }, { year: 1, foo: "bar" }): Interval);
(Interval.before(DateTime.utc(), Duration.fromObject({ year: 1 })): Interval);
(Interval.before(DateTime.utc(), { year: 1 }): Interval);
(Interval.before(DateTime.utc(), 1231234): Interval);
(Interval.before(
{ year: 2017, month: 1 },
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdaysFormat("long", { foo: "bar" }): Array);
(DateTime.local().toJSDate(): Date);
DateTime.local(2012).toJSDate();
DateTime.local(2012, 1, 16).toJSDate();
(DateTime.utc().toJSDate(): Date);
DateTime.utc(2012).toJSDate();
DateTime.utc(2012, 1, 16).toJSDate();
var date: DateTime = DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT");
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", {});
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { zone: "America/Chicago" });
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { zone: new CustomZone() });
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { locale: "en-US" });
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", {
zone: "America/Chicago",
setZone: true,
locale: "en-US",
outputCalendar: "gregory",
numberingSystem: "buddhist"
});
// $ExpectError
(Info.weekdaysFormat("long"): Array);
(Info.weekdaysFormat("narrow", { locale: "de-DE" }): Array);
(Info.weekdaysFormat("short", { numberingSystem: "arab" }): Array);
(Info.weekdaysFormat("long", {
numberingSystem: "latn",
outputCalendar: "buddhist"
}): Array);
// $ExpectError
(Info.weekdaysFormat("long", { foo: "bar" }): Array);
(DateTime.local().toJSDate(): Date);
DateTime.local(2012).toJSDate();
DateTime.local(2012, 1, 16).toJSDate();
(DateTime.utc().toJSDate(): Date);
DateTime.utc(2012).toJSDate();
DateTime.utc(2012, 1, 16).toJSDate();
var date: DateTime = DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT");
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", {});
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { zone: "America/Chicago" });
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { zone: new CustomZone() });
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { locale: "en-US" });
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", {
zone: "America/Chicago",
setZone: true,
locale: "en-US",
outputCalendar: "gregory",
numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromHTTP();
(date.toSQLDate(): string);
(date.toSQLTime(): string);
(date.toSQLTime({}): string);
(date.toSQLTime({ includeZone: true, includeOffset: true }): string);
// $ExpectError
(date.toSQLTime({ blah: true }): string);
(date.toString(): string);
(date.toUTC(): DateTime);
(date.toUTC(32): DateTime);
(date.toUTC(32, { keepCalendarTime: true }): DateTime); // Support deprecated name for keepLocalTime
(date.toUTC(32, { keepLocalTime: true }): DateTime);
(date.until(DateTime.utc()): Interval);
(date.valueOf(): number);
(Duration.fromISO("lkasdfa"): Duration);
(Duration.fromISO("lkasdfa", {
locale: "de-DE",
numberingSystem: "gujr",
conversionAccuracy: "casual"
}): Duration);
// $ExpectError
(Duration.fromISO(): Duration);
// $ExpectError
(Duration.fromISO("lkasdfa", { foo: "bar" }): Duration);
(Duration.fromObject({ year: 1 }): Duration);
(Duration.fromObject({ years: 1 }): Duration);