Skip to content

Commit 292eb69

Browse files
committed
feat(getNow): Improve the current time acquisition method
background: ant-design/ant-design#50934
1 parent 7689208 commit 292eb69

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/generate/dayjs.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ const parseNoMatchNotice = () => {
107107

108108
const generateConfig: GenerateConfig<Dayjs> = {
109109
// get
110-
getNow: () => dayjs(),
110+
getNow: () => {
111+
if (typeof dayjs.tz === 'function') {
112+
// https://github.com/ant-design/ant-design/discussions/50934
113+
return dayjs.tz();
114+
}
115+
return dayjs();
116+
},
111117
getFixedDate: (string) => dayjs(string, ['YYYY-M-DD', 'YYYY-MM-DD']),
112118
getEndDate: (date) => date.endOf('month'),
113119
getWeekDay: (date) => {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"src/**/*.tsx",
2020
"docs/examples/*.tsx",
2121
"tests/**/*.ts",
22-
"tests/**/*.tsx"
22+
"tests/**/*.tsx",
23+
"typings.d.ts"
2324
]
2425
}

typings.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'dayjs/plugin/timezone';
2+
3+
export {};

0 commit comments

Comments
 (0)