Browse Source

Even numbers don't seem to be kosher, only strings work

Manav Rathi 1 year ago
parent
commit
28cf7d76d5
1 changed files with 8 additions and 6 deletions
  1. 8 6
      web/apps/photos/src/components/FixCreationTime.tsx

+ 8 - 6
web/apps/photos/src/components/FixCreationTime.tsx

@@ -32,12 +32,12 @@ export type FixOption =
 interface FormValues {
 interface FormValues {
     option: FixOption;
     option: FixOption;
     /**
     /**
-     * Date.getTime()
+     * Date.toISOString()
      *
      *
      * Formik doesn't have native support for JS dates, so we instead keep the
      * Formik doesn't have native support for JS dates, so we instead keep the
-     * corresponding date's epoch milliseconds as the form state.
+     * corresponding date's ISO string representation as the form state.
      */
      */
-    customTime: number;
+    customTimeString: string;
 }
 }
 
 
 interface FixCreationTimeProps {
 interface FixCreationTimeProps {
@@ -69,7 +69,7 @@ const FixCreationTime: React.FC<FixCreationTimeProps> = (props) => {
         const completedWithErrors = await updateCreationTimeWithExif(
         const completedWithErrors = await updateCreationTimeWithExif(
             props.attributes.files,
             props.attributes.files,
             values.option,
             values.option,
-            new Date(values.customTime),
+            new Date(values.customTimeString),
             setProgressTracker,
             setProgressTracker,
         );
         );
         setStep(completedWithErrors ? "completed-with-errors" : "completed");
         setStep(completedWithErrors ? "completed-with-errors" : "completed");
@@ -138,7 +138,7 @@ const OptionsForm: React.FC<OptionsFormProps> = ({ step, onSubmit, hide }) => {
     const { values, handleChange, handleSubmit } = useFormik({
     const { values, handleChange, handleSubmit } = useFormik({
         initialValues: {
         initialValues: {
             option: "date-time-original",
             option: "date-time-original",
-            customTime: Date.now(),
+            customTimeString: new Date().toISOString(),
         },
         },
         validateOnBlur: false,
         validateOnBlur: false,
         onSubmit,
         onSubmit,
@@ -179,7 +179,9 @@ const OptionsForm: React.FC<OptionsFormProps> = ({ step, onSubmit, hide }) => {
                         {values.option === "custom-time" && (
                         {values.option === "custom-time" && (
                             <EnteDateTimePicker
                             <EnteDateTimePicker
                                 onSubmit={(d: Date) =>
                                 onSubmit={(d: Date) =>
-                                    handleChange("customTime")(d.getTime())
+                                    handleChange("customTimeString")(
+                                        d.toISOString(),
+                                    )
                                 }
                                 }
                             />
                             />
                         )}
                         )}