@checkdigit/time 4.0.0-PR.18-81a3 → 4.0.0-PR.18-e0fa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/package.json +1 -1
- package/src/date-fns/_lib/addLeadingZeros/test.mts +0 -12
- package/src/date-fns/_lib/getRoundingMethod/test.mts +0 -50
- package/src/date-fns/_lib/getTimezoneOffsetInMilliseconds/test.mts +0 -25
- package/src/date-fns/add/test.mts +0 -95
- package/src/date-fns/addBusinessDays/test.mts +0 -78
- package/src/date-fns/addDays/test.mts +0 -90
- package/src/date-fns/addHours/test.mts +0 -30
- package/src/date-fns/addISOWeekYears/test.mts +0 -41
- package/src/date-fns/addMilliseconds/test.mts +0 -30
- package/src/date-fns/addMinutes/test.mts +0 -30
- package/src/date-fns/addMonths/test.mts +0 -123
- package/src/date-fns/addQuarters/test.mts +0 -47
- package/src/date-fns/addSeconds/test.mts +0 -30
- package/src/date-fns/addWeeks/test.mts +0 -30
- package/src/date-fns/addYears/test.mts +0 -46
- package/src/date-fns/areIntervalsOverlapping/test.mts +0 -231
- package/src/date-fns/clamp/test.mts +0 -36
- package/src/date-fns/closestIndexTo/test.mts +0 -51
- package/src/date-fns/closestTo/test.mts +0 -49
- package/src/date-fns/compareAsc/test.mts +0 -58
- package/src/date-fns/compareDesc/test.mts +0 -58
- package/src/date-fns/constructFrom/test.mts +0 -47
- package/src/date-fns/constructNow/test.mts +0 -37
- package/src/date-fns/daysToWeeks/test.mts +0 -36
- package/src/date-fns/differenceInBusinessDays/test.mts +0 -102
- package/src/date-fns/differenceInCalendarDays/test.mts +0 -206
- package/src/date-fns/differenceInCalendarISOWeekYears/test.mts +0 -93
- package/src/date-fns/differenceInCalendarISOWeeks/test.mts +0 -89
- package/src/date-fns/differenceInCalendarMonths/test.mts +0 -82
- package/src/date-fns/differenceInCalendarQuarters/test.mts +0 -82
- package/src/date-fns/differenceInCalendarWeeks/test.mts +0 -136
- package/src/date-fns/differenceInCalendarYears/test.mts +0 -82
- package/src/date-fns/differenceInDays/test.mts +0 -175
- package/src/date-fns/differenceInHours/test.mts +0 -122
- package/src/date-fns/differenceInISOWeekYears/test.mts +0 -93
- package/src/date-fns/differenceInMilliseconds/test.mts +0 -53
- package/src/date-fns/differenceInMinutes/test.mts +0 -123
- package/src/date-fns/differenceInMonths/test.mts +0 -121
- package/src/date-fns/differenceInQuarters/test.mts +0 -109
- package/src/date-fns/differenceInSeconds/test.mts +0 -144
- package/src/date-fns/differenceInWeeks/test.mts +0 -111
- package/src/date-fns/differenceInYears/test.mts +0 -97
- package/src/date-fns/eachDayOfInterval/test.mts +0 -164
- package/src/date-fns/eachHourOfInterval/test.mts +0 -154
- package/src/date-fns/eachMinuteOfInterval/test.mts +0 -159
- package/src/date-fns/eachMonthOfInterval/test.mts +0 -151
- package/src/date-fns/eachQuarterOfInterval/test.mts +0 -136
- package/src/date-fns/eachWeekOfInterval/test.mts +0 -177
- package/src/date-fns/eachWeekendOfInterval/test.mts +0 -67
- package/src/date-fns/eachWeekendOfMonth/test.mts +0 -23
- package/src/date-fns/eachWeekendOfYear/test.mts +0 -18
- package/src/date-fns/eachYearOfInterval/test.mts +0 -136
- package/src/date-fns/endOfDay/test.mts +0 -27
- package/src/date-fns/endOfDecade/test.mts +0 -32
- package/src/date-fns/endOfHour/test.mts +0 -26
- package/src/date-fns/endOfISOWeek/test.mts +0 -27
- package/src/date-fns/endOfISOWeekYear/test.mts +0 -36
- package/src/date-fns/endOfMinute/test.mts +0 -26
- package/src/date-fns/endOfMonth/test.mts +0 -41
- package/src/date-fns/endOfQuarter/test.mts +0 -27
- package/src/date-fns/endOfSecond/test.mts +0 -26
- package/src/date-fns/endOfToday/test.mts +0 -19
- package/src/date-fns/endOfTomorrow/test.mts +0 -29
- package/src/date-fns/endOfWeek/test.mts +0 -86
- package/src/date-fns/endOfYear/test.mts +0 -27
- package/src/date-fns/endOfYesterday/test.mts +0 -29
- package/src/date-fns/format/test.mts +0 -909
- package/src/date-fns/formatDistance/test.mts +0 -189
- package/src/date-fns/formatDistanceStrict/test.mts +0 -329
- package/src/date-fns/formatDistanceToNow/test.mts +0 -196
- package/src/date-fns/formatDistanceToNowStrict/test.mts +0 -293
- package/src/date-fns/formatDuration/test.mts +0 -74
- package/src/date-fns/formatISO/test.mts +0 -55
- package/src/date-fns/formatISO9075/test.mts +0 -35
- package/src/date-fns/formatISODuration/test.mts +0 -75
- package/src/date-fns/formatRFC3339/test.mts +0 -41
- package/src/date-fns/formatRFC7231/test.mts +0 -18
- package/src/date-fns/formatRelative/test.mts +0 -92
- package/src/date-fns/fp/_lib/convertToFP/test.mts +0 -114
- package/src/date-fns/fromUnixTime/test.mts +0 -14
- package/src/date-fns/getDate/test.mts +0 -19
- package/src/date-fns/getDay/test.mts +0 -19
- package/src/date-fns/getDayOfYear/test.mts +0 -27
- package/src/date-fns/getDaysInMonth/test.mts +0 -33
- package/src/date-fns/getDaysInYear/test.mts +0 -35
- package/src/date-fns/getDecade/test.mts +0 -24
- package/src/date-fns/getDefaultOptions/test.mts +0 -58
- package/src/date-fns/getHours/test.mts +0 -19
- package/src/date-fns/getISODay/test.mts +0 -24
- package/src/date-fns/getISOWeek/test.mts +0 -54
- package/src/date-fns/getISOWeekYear/test.mts +0 -27
- package/src/date-fns/getISOWeeksInYear/test.mts +0 -37
- package/src/date-fns/getMilliseconds/test.mts +0 -19
- package/src/date-fns/getMinutes/test.mts +0 -19
- package/src/date-fns/getMonth/test.mts +0 -19
- package/src/date-fns/getOverlappingDaysInIntervals/test.mts +0 -243
- package/src/date-fns/getQuarter/test.mts +0 -19
- package/src/date-fns/getSeconds/test.mts +0 -19
- package/src/date-fns/getTime/test.mts +0 -21
- package/src/date-fns/getUnixTime/test.mts +0 -26
- package/src/date-fns/getWeek/test.mts +0 -56
- package/src/date-fns/getWeekOfMonth/test.mts +0 -75
- package/src/date-fns/getWeekYear/test.mts +0 -49
- package/src/date-fns/getWeeksInMonth/test.mts +0 -51
- package/src/date-fns/getYear/test.mts +0 -19
- package/src/date-fns/hoursToMilliseconds/test.mts +0 -23
- package/src/date-fns/hoursToMinutes/test.mts +0 -25
- package/src/date-fns/hoursToSeconds/test.mts +0 -25
- package/src/date-fns/interval/test.mts +0 -42
- package/src/date-fns/intervalToDuration/test.mts +0 -235
- package/src/date-fns/intlFormat/test.mts +0 -88
- package/src/date-fns/intlFormatDistance/test.mts +0 -588
- package/src/date-fns/isAfter/test.mts +0 -39
- package/src/date-fns/isBefore/test.mts +0 -39
- package/src/date-fns/isDate/test.mts +0 -72
- package/src/date-fns/isEqual/test.mts +0 -34
- package/src/date-fns/isExists/test.mts +0 -14
- package/src/date-fns/isFirstDayOfMonth/test.mts +0 -25
- package/src/date-fns/isFriday/test.mts +0 -24
- package/src/date-fns/isFuture/test.mts +0 -34
- package/src/date-fns/isLastDayOfMonth/test.mts +0 -25
- package/src/date-fns/isLeapYear/test.mts +0 -35
- package/src/date-fns/isMatch/test.mts +0 -27
- package/src/date-fns/isMonday/test.mts +0 -24
- package/src/date-fns/isPast/test.mts +0 -34
- package/src/date-fns/isSameDay/test.mts +0 -37
- package/src/date-fns/isSameHour/test.mts +0 -37
- package/src/date-fns/isSameISOWeek/test.mts +0 -34
- package/src/date-fns/isSameISOWeekYear/test.mts +0 -48
- package/src/date-fns/isSameMinute/test.mts +0 -37
- package/src/date-fns/isSameMonth/test.mts +0 -34
- package/src/date-fns/isSameQuarter/test.mts +0 -34
- package/src/date-fns/isSameSecond/test.mts +0 -43
- package/src/date-fns/isSameWeek/test.mts +0 -58
- package/src/date-fns/isSameYear/test.mts +0 -34
- package/src/date-fns/isSaturday/test.mts +0 -24
- package/src/date-fns/isSunday/test.mts +0 -24
- package/src/date-fns/isThisHour/test.mts +0 -34
- package/src/date-fns/isThisISOWeek/test.mts +0 -34
- package/src/date-fns/isThisMinute/test.mts +0 -34
- package/src/date-fns/isThisMonth/test.mts +0 -34
- package/src/date-fns/isThisQuarter/test.mts +0 -34
- package/src/date-fns/isThisSecond/test.mts +0 -34
- package/src/date-fns/isThisWeek/test.mts +0 -39
- package/src/date-fns/isThisYear/test.mts +0 -34
- package/src/date-fns/isThursday/test.mts +0 -24
- package/src/date-fns/isToday/test.mts +0 -34
- package/src/date-fns/isTomorrow/test.mts +0 -34
- package/src/date-fns/isTuesday/test.mts +0 -24
- package/src/date-fns/isValid/test.mts +0 -24
- package/src/date-fns/isWednesday/test.mts +0 -24
- package/src/date-fns/isWeekend/test.mts +0 -24
- package/src/date-fns/isWithinInterval/test.mts +0 -92
- package/src/date-fns/isYesterday/test.mts +0 -34
- package/src/date-fns/lastDayOfDecade/test.mts +0 -32
- package/src/date-fns/lastDayOfISOWeek/test.mts +0 -27
- package/src/date-fns/lastDayOfISOWeekYear/test.mts +0 -36
- package/src/date-fns/lastDayOfMonth/test.mts +0 -41
- package/src/date-fns/lastDayOfQuarter/test.mts +0 -27
- package/src/date-fns/lastDayOfWeek/test.mts +0 -86
- package/src/date-fns/lastDayOfYear/test.mts +0 -27
- package/src/date-fns/lightFormat/test.mts +0 -126
- package/src/date-fns/max/test.mts +0 -34
- package/src/date-fns/milliseconds/test.mts +0 -62
- package/src/date-fns/millisecondsToHours/test.mts +0 -24
- package/src/date-fns/millisecondsToMinutes/test.mts +0 -24
- package/src/date-fns/millisecondsToSeconds/test.mts +0 -24
- package/src/date-fns/min/test.mts +0 -34
- package/src/date-fns/minutesToHours/test.mts +0 -24
- package/src/date-fns/minutesToMilliseconds/test.mts +0 -23
- package/src/date-fns/minutesToSeconds/test.mts +0 -23
- package/src/date-fns/monthsToQuarters/test.mts +0 -24
- package/src/date-fns/monthsToYears/test.mts +0 -24
- package/src/date-fns/nextDay/test.mts +0 -44
- package/src/date-fns/nextFriday/test.mts +0 -24
- package/src/date-fns/nextMonday/test.mts +0 -24
- package/src/date-fns/nextSaturday/test.mts +0 -24
- package/src/date-fns/nextSunday/test.mts +0 -24
- package/src/date-fns/nextThursday/test.mts +0 -24
- package/src/date-fns/nextTuesday/test.mts +0 -23
- package/src/date-fns/nextWednesday/test.mts +0 -24
- package/src/date-fns/parse/test.mts +0 -2202
- package/src/date-fns/parseISO/test.mts +0 -362
- package/src/date-fns/parseJSON/test.mts +0 -129
- package/src/date-fns/previousDay/test.mts +0 -42
- package/src/date-fns/previousFriday/test.mts +0 -22
- package/src/date-fns/previousMonday/test.mts +0 -22
- package/src/date-fns/previousSaturday/test.mts +0 -22
- package/src/date-fns/previousSunday/test.mts +0 -22
- package/src/date-fns/previousThursday/test.mts +0 -22
- package/src/date-fns/previousTuesday/test.mts +0 -22
- package/src/date-fns/previousWednesday/test.mts +0 -22
- package/src/date-fns/quartersToMonths/test.mts +0 -24
- package/src/date-fns/quartersToYears/test.mts +0 -24
- package/src/date-fns/roundToNearestHours/test.mts +0 -200
- package/src/date-fns/roundToNearestMinutes/test.mts +0 -208
- package/src/date-fns/secondsToHours/test.mts +0 -24
- package/src/date-fns/secondsToMilliseconds/test.mts +0 -14
- package/src/date-fns/secondsToMinutes/test.mts +0 -24
- package/src/date-fns/set/test.mts +0 -121
- package/src/date-fns/setDate/test.mts +0 -30
- package/src/date-fns/setDay/test.mts +0 -112
- package/src/date-fns/setDayOfYear/test.mts +0 -30
- package/src/date-fns/setDefaultOptions/test.mts +0 -498
- package/src/date-fns/setHours/test.mts +0 -30
- package/src/date-fns/setISODay/test.mts +0 -59
- package/src/date-fns/setISOWeek/test.mts +0 -41
- package/src/date-fns/setISOWeekYear/test.mts +0 -50
- package/src/date-fns/setMilliseconds/test.mts +0 -30
- package/src/date-fns/setMinutes/test.mts +0 -30
- package/src/date-fns/setMonth/test.mts +0 -46
- package/src/date-fns/setQuarter/test.mts +0 -46
- package/src/date-fns/setSeconds/test.mts +0 -30
- package/src/date-fns/setWeek/test.mts +0 -63
- package/src/date-fns/setWeekYear/test.mts +0 -72
- package/src/date-fns/setYear/test.mts +0 -30
- package/src/date-fns/startOfDay/test.mts +0 -27
- package/src/date-fns/startOfDecade/test.mts +0 -32
- package/src/date-fns/startOfHour/test.mts +0 -27
- package/src/date-fns/startOfISOWeek/test.mts +0 -27
- package/src/date-fns/startOfISOWeekYear/test.mts +0 -41
- package/src/date-fns/startOfMinute/test.mts +0 -27
- package/src/date-fns/startOfMonth/test.mts +0 -27
- package/src/date-fns/startOfQuarter/test.mts +0 -27
- package/src/date-fns/startOfSecond/test.mts +0 -27
- package/src/date-fns/startOfToday/test.mts +0 -19
- package/src/date-fns/startOfTomorrow/test.mts +0 -29
- package/src/date-fns/startOfWeek/test.mts +0 -86
- package/src/date-fns/startOfWeekYear/test.mts +0 -58
- package/src/date-fns/startOfYear/test.mts +0 -38
- package/src/date-fns/startOfYesterday/test.mts +0 -29
- package/src/date-fns/sub/test.mts +0 -83
- package/src/date-fns/subBusinessDays/test.mts +0 -40
- package/src/date-fns/subDays/test.mts +0 -30
- package/src/date-fns/subHours/test.mts +0 -30
- package/src/date-fns/subISOWeekYears/test.mts +0 -41
- package/src/date-fns/subMilliseconds/test.mts +0 -30
- package/src/date-fns/subMinutes/test.mts +0 -30
- package/src/date-fns/subMonths/test.mts +0 -47
- package/src/date-fns/subQuarters/test.mts +0 -47
- package/src/date-fns/subSeconds/test.mts +0 -30
- package/src/date-fns/subWeeks/test.mts +0 -30
- package/src/date-fns/subYears/test.mts +0 -46
- package/src/date-fns/toDate/test.mts +0 -35
- package/src/date-fns/weeksToDays/test.mts +0 -24
- package/src/date-fns/yearsToDays/test.mts +0 -24
- package/src/date-fns/yearsToMonths/test.mts +0 -24
- package/src/date-fns/yearsToQuarters/test.mts +0 -24
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
|
-
import { assertType } from '../_lib/test/index';
|
|
3
|
-
import { isDate } from './index';
|
|
4
|
-
|
|
5
|
-
describe('isDate', () => {
|
|
6
|
-
it('returns true if the given value is a date object', () => {
|
|
7
|
-
expect(isDate(new Date())).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns true if the given value is an Invalid Date', () => {
|
|
11
|
-
expect(isDate(new Date(NaN))).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('ensures that the passed argument is an instance of Date', () => {
|
|
15
|
-
const date: unknown = new Date();
|
|
16
|
-
|
|
17
|
-
if (isDate(date)) {
|
|
18
|
-
assertType<Date>(date);
|
|
19
|
-
} else {
|
|
20
|
-
assertType<unknown>(date);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('with date passed from another iframe', () => {
|
|
25
|
-
// If in the browser, run the test in an iframe
|
|
26
|
-
if (typeof window !== 'undefined') {
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
const iframe = document.getElementById('iframe');
|
|
29
|
-
iframe && iframe.remove();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('returns true for a date passed from another iframe', () =>
|
|
33
|
-
new Promise((resolve) => {
|
|
34
|
-
const iframe = document.createElement('iframe');
|
|
35
|
-
iframe.id = 'iframe';
|
|
36
|
-
iframe.addEventListener('load', () => {
|
|
37
|
-
execScript('window.date = new Date()');
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- It's ok we're messing with iframes
|
|
39
|
-
expect(isDate((iframe.contentWindow as any).date)).toBe(true);
|
|
40
|
-
resolve(void 0);
|
|
41
|
-
});
|
|
42
|
-
if (!document.body) throw new Error('document.body is not defined');
|
|
43
|
-
document.body.appendChild(iframe);
|
|
44
|
-
}));
|
|
45
|
-
} else {
|
|
46
|
-
it.skip('returns true for a date passed from another iframe');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function execScript(scriptText: string) {
|
|
50
|
-
const iframe = document.querySelector('iframe#iframe');
|
|
51
|
-
if (!iframe || !(iframe instanceof HTMLIFrameElement)) {
|
|
52
|
-
throw new Error("Can't execute the script because iframe isn't found");
|
|
53
|
-
}
|
|
54
|
-
const doc = iframe.contentDocument!;
|
|
55
|
-
const script = doc.createElement('script');
|
|
56
|
-
script.innerText = scriptText;
|
|
57
|
-
// @ts-expect-error - We're messing with iframes
|
|
58
|
-
if (!(doc.body instanceof iframe.contentWindow.HTMLBodyElement)) {
|
|
59
|
-
throw new Error("Can't execute the script because iframe does not have body");
|
|
60
|
-
}
|
|
61
|
-
doc.body.append(script);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('returns false if the given value is not a date object', () => {
|
|
66
|
-
expect(!isDate(new Date().getTime())).toBe(true);
|
|
67
|
-
expect(!isDate(new Date().toISOString())).toBe(true);
|
|
68
|
-
expect(!isDate({})).toBe(true);
|
|
69
|
-
expect(!isDate(null)).toBe(true);
|
|
70
|
-
expect(!isDate(0)).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isEqual } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isEqual', () => {
|
|
5
|
-
it('returns true if the given dates are equal', () => {
|
|
6
|
-
const result = isEqual(new Date(1987, 1 /* Feb */, 11), new Date(1987, 1 /* Feb */, 11));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates are not equal', () => {
|
|
11
|
-
const result = isEqual(new Date(1989, 6 /* Jul */, 10), new Date(1987, 1 /* Feb */, 11));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isEqual(new Date(1987, 1 /* Feb */, 11).getTime(), new Date(1987, 1 /* Feb */, 11).getTime());
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
21
|
-
const result = isEqual(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
26
|
-
const result = isEqual(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
31
|
-
const result = isEqual(new Date(NaN), new Date(NaN));
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isExists } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isValid', () => {
|
|
5
|
-
it('returns true if the given date is valid', () => {
|
|
6
|
-
const result = isExists(2018, 0, 31);
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given date is invalid', () => {
|
|
11
|
-
const result = isExists(2018, 1 /* Feb */, 31);
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isFirstDayOfMonth } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isFirstDayOfMonth', () => {
|
|
5
|
-
it('returns true if the given date is in the last day of month', () => {
|
|
6
|
-
const result = isFirstDayOfMonth(new Date(2014, 9 /* Oct */, 1));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given date is not in the last day of month', () => {
|
|
11
|
-
const result = isFirstDayOfMonth(new Date(2014, 9 /* Oct */, 2));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const date = new Date(2014, 9 /* Oct */, 1).getTime();
|
|
17
|
-
const result = isFirstDayOfMonth(date);
|
|
18
|
-
expect(result).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('returns false if the given date is `Invalid Date`', () => {
|
|
22
|
-
const result = isFirstDayOfMonth(new Date(NaN));
|
|
23
|
-
expect(result).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isFriday } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isFriday', () => {
|
|
5
|
-
it('returns true if the given date is Friday', () => {
|
|
6
|
-
const result = isFriday(new Date(2014, 8 /* Sep */, 26));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given date is not Friday', () => {
|
|
11
|
-
const result = isFriday(new Date(2014, 8 /* Sep */, 25));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isFriday(new Date(2014, 1 /* Feb */, 14).getTime());
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the given date is `Invalid Date`', () => {
|
|
21
|
-
const result = isFriday(new Date(NaN));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
-
import sinon from 'sinon';
|
|
3
|
-
import { isFuture } from './index';
|
|
4
|
-
|
|
5
|
-
describe('isFuture', () => {
|
|
6
|
-
let clock: sinon.SinonFakeTimers;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
clock = sinon.useFakeTimers(new Date(2014, 8 /* Sep */, 25).getTime());
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
clock.restore();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns true if the given date is in the future', () => {
|
|
16
|
-
const result = isFuture(new Date(2014, 9 /* Oct */, 31));
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the given date is in the past', () => {
|
|
21
|
-
const result = isFuture(new Date(2014, 8 /* Sep */, 1));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the given date is now', () => {
|
|
26
|
-
const result = isFuture(new Date(2014, 8 /* Sep */, 25));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('accepts a timestamp', () => {
|
|
31
|
-
const result = isFuture(new Date(2014, 9 /* Oct */, 31).getTime());
|
|
32
|
-
expect(result).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isLastDayOfMonth } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isLastDayOfMonth', () => {
|
|
5
|
-
it('returns true if the given date is in the last day of month', () => {
|
|
6
|
-
const result = isLastDayOfMonth(new Date(2014, 9 /* Oct */, 31));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given date is not in the last day of month', () => {
|
|
11
|
-
const result = isLastDayOfMonth(new Date(2014, 9 /* Oct */, 30));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const date = new Date(2014, 9 /* Oct */, 31).getTime();
|
|
17
|
-
const result = isLastDayOfMonth(date);
|
|
18
|
-
expect(result).toBe(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('returns false if the given date is `Invalid Date`', () => {
|
|
22
|
-
const result = isLastDayOfMonth(new Date(NaN));
|
|
23
|
-
expect(result).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isLeapYear } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isLeapYear', () => {
|
|
5
|
-
it('returns true if the given date is in the leap year', () => {
|
|
6
|
-
const result = isLeapYear(new Date(2012, 6 /* Jul */, 2));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given date is not in the leap year', () => {
|
|
11
|
-
const result = isLeapYear(new Date(2014, 6 /* Jul */, 2));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('works for the years divisible by 100 but not by 400', () => {
|
|
16
|
-
const result = isLeapYear(new Date(2100, 6 /* Jul */, 2));
|
|
17
|
-
expect(result).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('works for the years divisible by 400', () => {
|
|
21
|
-
const result = isLeapYear(new Date(2000, 6 /* Jul */, 2));
|
|
22
|
-
expect(result).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('accepts a timestamp', () => {
|
|
26
|
-
const date = new Date(2012, 6 /* Jul */, 2).getTime();
|
|
27
|
-
const result = isLeapYear(date);
|
|
28
|
-
expect(result).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('returns false if the given date is `Invalid Date`', () => {
|
|
32
|
-
const result = isLeapYear(new Date(NaN));
|
|
33
|
-
expect(result).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { beforeAll, describe, expect, it } from 'vitest';
|
|
2
|
-
import { isMatch } from './index';
|
|
3
|
-
import { Locale } from '../types';
|
|
4
|
-
|
|
5
|
-
describe.skip('isMatch', () => {
|
|
6
|
-
let eo: Locale;
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
// @ts-expect-error
|
|
9
|
-
({ eo } = await import('../locale/eo/index'));
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('accepts a dd-MM-yyyy format against 22-02-1998', () => {
|
|
13
|
-
expect(isMatch('22-02-1998', 'dd-MM-yyyy')).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('reject a yyyy-dd-MM format against 22-02-1998', () => {
|
|
17
|
-
expect(!isMatch('22-02-1998', 'yyyy-dd-MM')).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('accepts a date & format with locale', () => {
|
|
21
|
-
expect(
|
|
22
|
-
isMatch('28-a de februaro', "do 'de' MMMM", {
|
|
23
|
-
locale: eo,
|
|
24
|
-
}),
|
|
25
|
-
).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isMonday } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isMonday', () => {
|
|
5
|
-
it('returns true if the given date is Monday', () => {
|
|
6
|
-
const result = isMonday(new Date(2014, 8 /* Sep */, 22));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given date is not Monday', () => {
|
|
11
|
-
const result = isMonday(new Date(2014, 8 /* Sep */, 25));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isMonday(new Date(2014, 1 /* Feb */, 10).getTime());
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the given date is `Invalid Date`', () => {
|
|
21
|
-
const result = isMonday(new Date(NaN));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
-
import sinon from 'sinon';
|
|
3
|
-
import { isPast } from './index';
|
|
4
|
-
|
|
5
|
-
describe('isPast', () => {
|
|
6
|
-
let clock: sinon.SinonFakeTimers;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
clock = sinon.useFakeTimers(new Date(2014, 8 /* Sep */, 25).getTime());
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
clock.restore();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns true if the given date is in the past', () => {
|
|
16
|
-
const result = isPast(new Date(2014, 6 /* Jul */, 2));
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the given date is in the future', () => {
|
|
21
|
-
const result = isPast(new Date(2014, 11 /* Dec */, 31));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the given date is now', () => {
|
|
26
|
-
const result = isPast(new Date(2014, 8 /* Sep */, 25));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('accepts a timestamp', () => {
|
|
31
|
-
const result = isPast(new Date(2014, 6 /* Jul */, 2).getTime());
|
|
32
|
-
expect(result).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameDay } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameDay', () => {
|
|
5
|
-
it('returns true if the given dates have the same day', () => {
|
|
6
|
-
const result = isSameDay(new Date(2014, 8 /* Sep */, 4, 6, 0), new Date(2014, 8 /* Sep */, 4, 18, 0));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different days', () => {
|
|
11
|
-
const result = isSameDay(new Date(2014, 8 /* Sep */, 4, 23, 59), new Date(2014, 8 /* Sep */, 5, 0, 0));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameDay(
|
|
17
|
-
new Date(2014, 8 /* Sep */, 4, 6, 0).getTime(),
|
|
18
|
-
new Date(2014, 8 /* Sep */, 4, 18, 0).getTime(),
|
|
19
|
-
);
|
|
20
|
-
expect(result).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
24
|
-
const result = isSameDay(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
25
|
-
expect(result).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
29
|
-
const result = isSameDay(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
30
|
-
expect(result).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
34
|
-
const result = isSameDay(new Date(NaN), new Date(NaN));
|
|
35
|
-
expect(result).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameHour } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameHour', () => {
|
|
5
|
-
it('returns true if the given dates have the same hour', () => {
|
|
6
|
-
const result = isSameHour(new Date(2014, 8 /* Sep */, 4, 6, 0), new Date(2014, 8 /* Sep */, 4, 6, 30));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different hours', () => {
|
|
11
|
-
const result = isSameHour(new Date(2014, 8 /* Sep */, 4, 6, 0), new Date(2014, 8 /* Sep */, 4, 5, 0));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameHour(
|
|
17
|
-
new Date(2014, 8 /* Sep */, 4, 18, 0).getTime(),
|
|
18
|
-
new Date(2014, 8 /* Sep */, 4, 18, 45).getTime(),
|
|
19
|
-
);
|
|
20
|
-
expect(result).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
24
|
-
const result = isSameHour(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
25
|
-
expect(result).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
29
|
-
const result = isSameHour(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
30
|
-
expect(result).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
34
|
-
const result = isSameHour(new Date(NaN), new Date(NaN));
|
|
35
|
-
expect(result).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameISOWeek } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameISOWeek', () => {
|
|
5
|
-
it('returns true if the given dates have the same ISO week', () => {
|
|
6
|
-
const result = isSameISOWeek(new Date(2014, 8 /* Sep */, 1), new Date(2014, 8 /* Sep */, 7));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different ISO weeks', () => {
|
|
11
|
-
const result = isSameISOWeek(new Date(2014, 8 /* Sep */, 1), new Date(2014, 8 /* Sep */, 14));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameISOWeek(new Date(2014, 5 /* Jun */, 30).getTime(), new Date(2014, 6 /* Jul */, 2).getTime());
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
21
|
-
const result = isSameISOWeek(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
26
|
-
const result = isSameISOWeek(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
31
|
-
const result = isSameISOWeek(new Date(NaN), new Date(NaN));
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameISOWeekYear } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameISOWeekYear', () => {
|
|
5
|
-
it('returns true if the given dates have the same ISO week-numbering year', () => {
|
|
6
|
-
const result = isSameISOWeekYear(new Date(2003, 11 /* Dec */, 29), new Date(2005, 0 /* Jan */, 2));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different ISO week-numbering years', () => {
|
|
11
|
-
const result = isSameISOWeekYear(new Date(2014, 11 /* Dec */, 28), new Date(2014, 11 /* Dec */, 29));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameISOWeekYear(
|
|
17
|
-
new Date(2003, 11 /* Dec */, 29).getTime(),
|
|
18
|
-
new Date(2005, 0 /* Jan */, 2).getTime(),
|
|
19
|
-
);
|
|
20
|
-
expect(result).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('handles dates before 100 AD', () => {
|
|
24
|
-
const firstDate = new Date(0);
|
|
25
|
-
firstDate.setFullYear(5, 0 /* Jan */, 1);
|
|
26
|
-
firstDate.setHours(0, 0, 0, 0);
|
|
27
|
-
const secondDate = new Date(0);
|
|
28
|
-
secondDate.setFullYear(5, 0 /* Jan */, 2);
|
|
29
|
-
secondDate.setHours(0, 0, 0, 0);
|
|
30
|
-
const result = isSameISOWeekYear(firstDate, secondDate);
|
|
31
|
-
expect(result).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
35
|
-
const result = isSameISOWeekYear(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
36
|
-
expect(result).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
40
|
-
const result = isSameISOWeekYear(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
41
|
-
expect(result).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
45
|
-
const result = isSameISOWeekYear(new Date(NaN), new Date(NaN));
|
|
46
|
-
expect(result).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameMinute } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameMinute', () => {
|
|
5
|
-
it('returns true if the given dates have the same minute', () => {
|
|
6
|
-
const result = isSameMinute(new Date(2014, 8 /* Sep */, 4, 6, 30), new Date(2014, 8 /* Sep */, 4, 6, 30, 15));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different minutes', () => {
|
|
11
|
-
const result = isSameMinute(new Date(2014, 8 /* Sep */, 4, 6, 30, 59), new Date(2014, 8 /* Sep */, 4, 6, 31));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameMinute(
|
|
17
|
-
new Date(2014, 8 /* Sep */, 4, 18, 45).getTime(),
|
|
18
|
-
new Date(2014, 8 /* Sep */, 4, 18, 45, 30).getTime(),
|
|
19
|
-
);
|
|
20
|
-
expect(result).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
24
|
-
const result = isSameMinute(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
25
|
-
expect(result).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
29
|
-
const result = isSameMinute(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
30
|
-
expect(result).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
34
|
-
const result = isSameMinute(new Date(NaN), new Date(NaN));
|
|
35
|
-
expect(result).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameMonth } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameMonth', () => {
|
|
5
|
-
it('returns true if the given dates have the same month (and year)', () => {
|
|
6
|
-
const result = isSameMonth(new Date(2014, 8 /* Sep */, 2), new Date(2014, 8 /* Sep */, 25));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different months', () => {
|
|
11
|
-
const result = isSameMonth(new Date(2014, 8 /* Sep */, 2), new Date(2013, 8 /* Sep */, 25));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameMonth(new Date(2014, 8 /* Sep */, 2).getTime(), new Date(2014, 8 /* Sep */, 25).getTime());
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
21
|
-
const result = isSameMonth(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
26
|
-
const result = isSameMonth(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
31
|
-
const result = isSameMonth(new Date(NaN), new Date(NaN));
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameQuarter } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameQuarter', () => {
|
|
5
|
-
it('returns true if the given dates have the same quarter (and year)', () => {
|
|
6
|
-
const result = isSameQuarter(new Date(2014, 0 /* Jan */, 1), new Date(2014, 2 /* Mar */, 8));
|
|
7
|
-
expect(result).toBe(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('returns false if the given dates have different quarters', () => {
|
|
11
|
-
const result = isSameQuarter(new Date(2014, 0 /* Jan */, 1), new Date(2013, 8 /* Sep */, 25));
|
|
12
|
-
expect(result).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('accepts a timestamp', () => {
|
|
16
|
-
const result = isSameQuarter(new Date(2014, 6 /* Jul */, 2).getTime(), new Date(2014, 8 /* Sep */, 25).getTime());
|
|
17
|
-
expect(result).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
21
|
-
const result = isSameQuarter(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
22
|
-
expect(result).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
26
|
-
const result = isSameQuarter(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
27
|
-
expect(result).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
31
|
-
const result = isSameQuarter(new Date(NaN), new Date(NaN));
|
|
32
|
-
expect(result).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { isSameSecond } from './index';
|
|
3
|
-
|
|
4
|
-
describe('isSameSecond', () => {
|
|
5
|
-
it('returns true if the given dates have the same second', () => {
|
|
6
|
-
const result = isSameSecond(
|
|
7
|
-
new Date(2014, 8 /* Sep */, 4, 6, 30, 15),
|
|
8
|
-
new Date(2014, 8 /* Sep */, 4, 6, 30, 15, 500),
|
|
9
|
-
);
|
|
10
|
-
expect(result).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('returns false if the given dates have different seconds', () => {
|
|
14
|
-
const result = isSameSecond(
|
|
15
|
-
new Date(2014, 8 /* Sep */, 4, 6, 30, 58, 999),
|
|
16
|
-
new Date(2014, 8 /* Sep */, 4, 6, 30, 59),
|
|
17
|
-
);
|
|
18
|
-
expect(result).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('accepts a timestamp', () => {
|
|
22
|
-
const result = isSameSecond(
|
|
23
|
-
new Date(2014, 8 /* Sep */, 4, 18, 45, 30).getTime(),
|
|
24
|
-
new Date(2014, 8 /* Sep */, 4, 18, 45, 30, 400).getTime(),
|
|
25
|
-
);
|
|
26
|
-
expect(result).toBe(true);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('returns false if the first date is `Invalid Date`', () => {
|
|
30
|
-
const result = isSameSecond(new Date(NaN), new Date(1989, 6 /* Jul */, 10));
|
|
31
|
-
expect(result).toBe(false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('returns false if the second date is `Invalid Date`', () => {
|
|
35
|
-
const result = isSameSecond(new Date(1987, 1 /* Feb */, 11), new Date(NaN));
|
|
36
|
-
expect(result).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('returns false if the both dates are `Invalid Date`', () => {
|
|
40
|
-
const result = isSameSecond(new Date(NaN), new Date(NaN));
|
|
41
|
-
expect(result).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
});
|