Skip to content

Commit b4f28df

Browse files
authored
fix: update UTC plugin type file for strict parsing (#1443)
1 parent aa5b524 commit b4f28df

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

docs/en/Plugin.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,16 @@ dayjs
8787
.local()
8888
.format() //2019-03-06T17:11:55+08:00
8989
dayjs.utc('2018-01-01', 'YYYY-MM-DD') // with CustomParseFormat plugin
90+
dayjs.utc('2018-01-01', 'YYYY-MM-DD', true) // with CustomParseFormat plugin & Using strict parsing
9091
```
9192

9293
By default, Day.js parses and displays in local time.
9394

9495
If you want to parse or display in UTC, you can use `dayjs.utc()` instead of `dayjs()`.
9596

96-
#### dayjs.utc `dayjs.utc(dateType?: string | number | Date | Dayjs, format? string)`
97+
You may specify a boolean for the last argument to use `strict parsing`. Strict parsing requires that the format and input match exactly, including delimiters.
98+
99+
#### dayjs.utc `dayjs.utc(dateType?: string | number | Date | Dayjs, format? string, strict?: boolean)`
97100

98101
Returns a `Dayjs` object in UTC mode.
99102

types/plugin/utc.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ declare module 'dayjs' {
1515
utcOffset(offset: number, keepLocalTime?: boolean): Dayjs
1616
}
1717

18-
export function utc(config?: ConfigType, format?: string): Dayjs
18+
export function utc(config?: ConfigType, format?: string, strict?: boolean): Dayjs
1919
}

0 commit comments

Comments
 (0)