commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r809159 - in /commons/sandbox/runtime/trunk/src/main/native: os/unix/time.c test/testsuite.c
Date Sat, 29 Aug 2009 16:56:16 GMT
Author: mturk
Date: Sat Aug 29 16:56:16 2009
New Revision: 809159

URL: http://svn.apache.org/viewvc?rev=809159&view=rev
Log:
Fix dos date overflow

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c?rev=809159&r1=809158&r2=809159&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c Sat Aug 29 16:56:16 2009
@@ -90,7 +90,6 @@
 #else
     tm = *gmtime(&tt);
 #endif
-    printf("Year is %d\n", tm.tm_year);
     if (tm.tm_year >= 1900)
         tm.tm_year -= 1900;
     if (tm.tm_year < 80) {
@@ -101,7 +100,7 @@
     }
     else
         tm.tm_year -= 80;
-    if (tm.tm_year > 207) {
+    if (tm.tm_year > 127) {
         /* December 31st 2107 is the
          * maximum date DOS format can handle.
          */

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=809159&r1=809158&r2=809159&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sat Aug 29 16:56:16 2009
@@ -412,6 +412,7 @@
  */
 static acr_time_t test_2002 = ACR_INT64_C(1032030336186711);
 static acr_time_t test_2107 = ACR_INT64_C(4354732800000000); /* Max Dos date */
+static acr_time_t test_2108 = ACR_INT64_C(4354819200000000);
 static acr_time_t test_1980 = ACR_INT64_C(315532800000000);  /* Min Dos date */
 
 static int test_times(int argc, const char *const argv[])
@@ -448,6 +449,12 @@
     printf("Dos Time 2 is %04x - %04x\n",  d2 >> 16, d2 & 0xffff);
     printf("Acr Time 2 is %" ACR_INT64_T_FMT "\n", ACR_Dos2AcrTime(d2));
     printf("Acr Time 2 is %" ACR_INT64_T_FMT "\n", ACR_Dos2AcrTime(d2+1));
+    d2 = ACR_Acr2DosTime(test_2108);
+    t1 = ACR_Dos2AcrTime(d2);
+    if (t1 != test_2107)
+        failed++;
+    printf("Dos Time 3 is %04x - %04x\n",  d2 >> 16, d2 & 0xffff);
+    printf("Acr Time 3 is %" ACR_INT64_T_FMT "\n", t1);
 
     tests_failed += failed;
     if (failed)



Mime
View raw message