瀏覽代碼

Merge pull request #1955 from DouyinFE/fix-1953

fix: when format is HH make the default value correct
代强 1 年之前
父節點
當前提交
a1245bbd14

+ 1 - 1
packages/semi-foundation/timePicker/utils/index.ts

@@ -14,7 +14,7 @@ import { zhCN as defaultLocale } from 'date-fns/locale';
 export const parseToDate = (input: string | Date | number, formatToken = strings.DEFAULT_FORMAT, dateFnsLocale = defaultLocale) => {
     if (input instanceof Date) {
         return input;
-    } else if (typeof input === 'number' || !isNaN(Number(input))) {
+    } else if (typeof input === 'number') {
         return new Date(toNumber(input));
     } else if (typeof input === 'string') {
         let curDate = new Date();

+ 6 - 0
packages/semi-ui/timePicker/_story/timepicker.stories.jsx

@@ -335,4 +335,10 @@ export const Fix1716 = () => {
 
 Fix1716.story = {
   name: 'Fix 1716',
+};
+
+export const Fix1953 = () => {
+  return (
+    <TimePicker format={'HH'} defaultValue={'10'}/>
+  );
 };