Skip to content

Commit

Permalink
refactor: replace date-fns with native implemetation
Browse files Browse the repository at this point in the history
  • Loading branch information
ItMaga committed Feb 8, 2024
1 parent cd26898 commit 3359f6c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@antfu/eslint-config-ts": "^0.38.4",
"@types/node": "^18.15.11",
"bumpp": "^9.1.0",
"date-fns": "^2.29.3",
"eslint": "^8.37.0",
"lint-staged": "^13.2.0",
"simple-git-hooks": "^2.8.1",
Expand Down
15 changes: 12 additions & 3 deletions tests/date.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, test } from 'vitest';
import { z } from 'zod';
import { endOfTomorrow, endOfYesterday } from 'date-fns';
import { expect } from './utils/expect';

describe('Date', () => {
Expand All @@ -10,12 +9,22 @@ describe('Date', () => {
expect(schema);
});
test('min', () => {
const schema = z.date().min(endOfTomorrow());
const now = new Date();
const endOfTomorrow = new Date(0);
endOfTomorrow.setFullYear(now.getFullYear(), now.getMonth(), now.getDate() + 1);
endOfTomorrow.setHours(23, 59, 59, 999);

const schema = z.date().min(endOfTomorrow);

expect(schema);
});
test('max', () => {
const schema = z.date().max(endOfYesterday());
const now = new Date();
const endOfYesterday = new Date(0);
endOfYesterday.setFullYear(now.getFullYear(), now.getMonth(), now.getDate() - 1);
endOfYesterday.setHours(23, 59, 59, 999);

const schema = z.date().max(endOfYesterday);

expect(schema);
});
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,6 @@ cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

date-fns@^2.29.3:
version "2.29.3"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==

debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
Expand Down

0 comments on commit 3359f6c

Please sign in to comment.