-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from zolplay-cn/cali
fix(utils): add support for parseDateTime
- Loading branch information
Showing
9 changed files
with
126 additions
and
11 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
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,32 @@ | ||
import { describe, expect, test } from 'vitest' | ||
|
||
import { parseDateTime } from '@/datetime' | ||
|
||
describe('datetime utils', () => { | ||
describe('parseDateTime', () => { | ||
test('should parse a string', () => { | ||
const parsed = parseDateTime('2021-01-01T10:00:00.000Z') | ||
|
||
expect(parsed?.year()).toBe(2021) | ||
expect(parsed?.toISOString()).toBe('2021-01-01T10:00:00.000Z') | ||
expect(parsed?.format('YYYY-MM-DD')).toBe('2021-01-01') | ||
}) | ||
|
||
test('should parse an object', () => { | ||
const parsed = parseDateTime({ date: '2022-01-01T09:00:00.000Z' }) | ||
|
||
expect(parsed?.year()).toBe(2022) | ||
expect(parsed?.toISOString()).toBe('2022-01-01T09:00:00.000Z') | ||
expect(parsed?.format('YYYY-MM-DD')).toBe('2022-01-01') | ||
}) | ||
|
||
test('should parse an object with timezone', () => { | ||
const parsed = parseDateTime({ | ||
date: '2023-01-01', | ||
timezone: 'Asia/Tokyo', | ||
}) | ||
|
||
expect(parsed?.toISOString()).toBe('2023-01-01T00:00:00.000Z') | ||
}) | ||
}) | ||
}) |
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
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{ | ||
"extends": "@zolplay/tsconfig/public-base.json", | ||
"compilerOptions": { | ||
"target": "ESNext" | ||
"target": "ESNext", | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./src/*"] | ||
} | ||
} | ||
} |
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,14 @@ | ||
/// <reference types="vitest" /> | ||
/// <reference types="vite/client" /> | ||
|
||
import { defineConfig } from 'vite' | ||
import tsconfigPaths from 'vite-tsconfig-paths' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [tsconfigPaths()], | ||
test: { | ||
globals: true, | ||
// setupFiles: './tests/setup.ts', | ||
}, | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.