Simplify formatter selection in Date/Picker.ts
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 7 Jan 2021 16:13:43 +0000 (17:13 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 8 Jan 2021 09:33:00 +0000 (10:33 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Date/Picker.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Date/Picker.ts

index e5b2960f7fd483d170d7ceb590726a0586ce460c..4b81eed9933f2d66ce5ac837ab067a18aea7fd12 100644 (file)
@@ -577,8 +577,17 @@ define(["require", "exports", "tslib", "../Core", "./Util", "../Dom/Change/Liste
                     }
                     else {
                         element.dataset.value = time.toString();
-                        const format = isTimeOnly ? "formatTime" : isDateTime ? "formatDateTime" : "formatDate";
-                        value = DateUtil[format](date);
+                        if (isTimeOnly) {
+                            value = DateUtil.formatTime(date);
+                        }
+                        else {
+                            if (isDateTime) {
+                                value = DateUtil.formatDateTime(date);
+                            }
+                            else {
+                                value = DateUtil.formatDate(date);
+                            }
+                        }
                     }
                 }
                 const isEmpty = value.length === 0;
index a8be9494fd1f4fe0f0c4962202dbd95acc8bb0a3..a4fe0b67e00f33512a3255eea787b61f94c3e773 100644 (file)
@@ -698,8 +698,15 @@ const DatePicker = {
             value = "";
           } else {
             element.dataset.value = time.toString();
-            const format = isTimeOnly ? "formatTime" : isDateTime ? "formatDateTime" : "formatDate";
-            value = DateUtil[format](date);
+            if (isTimeOnly) {
+              value = DateUtil.formatTime(date);
+            } else {
+              if (isDateTime) {
+                value = DateUtil.formatDateTime(date);
+              } else {
+                value = DateUtil.formatDate(date);
+              }
+            }
           }
         }