Fix CFXJSE_FormCalcContext::Time2Num().

Correctly calculate the number of microseconds in a day.

Change-Id: Ia4dbeafad7390f6834b15db3c8e07b44e503c773
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/78734
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index e999522..395275b 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -2483,13 +2483,12 @@
   const int32_t second = uniTime.GetSecond();
   const int32_t millisecond = uniTime.GetMillisecond();
 
+  constexpr int kMinutesInDay = 24 * 60;
   int32_t minutes_with_tz =
       hour * 60 + minute - (CXFA_TimeZoneProvider().GetTimeZone().tzHour * 60);
-  while (minutes_with_tz > 1440)
-    minutes_with_tz -= 1440;
-
-  while (minutes_with_tz < 0)
-    minutes_with_tz += 1440;
+  minutes_with_tz %= kMinutesInDay;
+  if (minutes_with_tz < 0)
+    minutes_with_tz += kMinutesInDay;
 
   hour = minutes_with_tz / 60;
   minute = minutes_with_tz % 60;
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
index 7f6b8b8..1fd347b 100644
--- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -514,10 +514,8 @@
     const char* program;
     int result;
   } tests[] = {
-      // TODO(thestig): Should be 1.
-      {"Time2Num(\"00:00:00 GMT\", \"HH:MM:SS Z\")", 86400001},
-      // TODO(thestig): Should be 1001.
-      {"Time2Num(\"00:00:01 GMT\", \"HH:MM:SS Z\")", 86401001},
+      {"Time2Num(\"00:00:00 GMT\", \"HH:MM:SS Z\")", 1},
+      {"Time2Num(\"00:00:01 GMT\", \"HH:MM:SS Z\")", 1001},
       {"Time2Num(\"00:01:00 GMT\", \"HH:MM:SS Z\")", 60001},
       {"Time2Num(\"01:00:00 GMT\", \"HH:MM:SS Z\")", 3600001},
       {"Time2Num(\"23:59:59 GMT\", \"HH:MM:SS Z\")", 86399001},