-Deactivate _invalid_parameter for now, depends on the strsafe crt implementation...
authorGregor Schneider <grschneider@gmail.com>
Thu, 6 Aug 2009 00:26:23 +0000 (00:26 +0000)
committerGregor Schneider <grschneider@gmail.com>
Thu, 6 Aug 2009 00:26:23 +0000 (00:26 +0000)
-Fix the weekday offset in gmtime
-Offset the year in *ctime by 1900, fix obvious typos
-Set structure packing to char level: without it the 26 character array is 32 characters wide and the string can't be constructed properly because of alignment characters in between (shouldn't be a problem when _UNICODE is defined)
-Test results: awesome, will be integrated soon

svn path=/trunk/; revision=42413

reactos/lib/sdk/crt/time_new/asctime.c
reactos/lib/sdk/crt/time_new/ftime.c
reactos/lib/sdk/crt/time_new/gmtime.c
reactos/lib/sdk/crt/time_new/localtime.c

index 4929ddf..33a9ffb 100644 (file)
@@ -12,6 +12,7 @@
 
 #define DAYSPERWEEK 7
 #define MONSPERYEAR 12
+#define HUNDREDYEAROFFSET 19
 
 static const _TCHAR wday_name[DAYSPERWEEK][4] =
 {
@@ -33,6 +34,7 @@ typedef unsigned long _TCHAR4;
 typedef unsigned short _TCHAR2;
 #endif
 
+#pragma pack(push,1)
 typedef union
 {
     _TCHAR text[26];
@@ -53,6 +55,7 @@ typedef union
         _TCHAR zt;
     };
 } timebuf_t;
+#pragma pack(pop)
 
 _TCHAR2
 static __inline__
@@ -80,13 +83,13 @@ FillBuf(timebuf_t *buf, const struct tm *ptm)
     buf->Month = *(_TCHAR4*)mon_name[ptm->tm_mon];
     buf->Day = IntToChar2(ptm->tm_mday);
     buf->Space1 = ' ';
-    buf->Hour = IntToChar2(ptm->tm_mday);
+    buf->Hour = IntToChar2(ptm->tm_hour);
     buf->Sep1 = ':';
-    buf->Minute = IntToChar2(ptm->tm_mday);
+    buf->Minute = IntToChar2(ptm->tm_min);
     buf->Sep2 = ':';
-    buf->Second = IntToChar2(ptm->tm_mday);
+    buf->Second = IntToChar2(ptm->tm_sec);
     buf->Space2 = ' ';
-    buf->Year[0] = IntToChar2(ptm->tm_year / 100);
+    buf->Year[0] = IntToChar2(ptm->tm_year / 100 + HUNDREDYEAROFFSET);
     buf->Year[1] = IntToChar2(ptm->tm_year % 100);
     buf->lb = '\n';
     buf->zt = '\0';
@@ -116,6 +119,7 @@ _tasctime_s(
         (unsigned int)ptm->tm_wday > 6 ||
         (unsigned int)ptm->tm_yday > 365)
     {
+#if 0
         _invalid_parameter(NULL,
 #ifdef UNICODE
                             L"_wasctime",
@@ -125,6 +129,7 @@ _tasctime_s(
                            _CRT_WIDE(__FILE__),
                            __LINE__,
                            0);
+#endif
         return EINVAL;
     }
 
index 5e63045..9f432e4 100644 (file)
@@ -27,11 +27,13 @@ _ftime_s(struct _timeb *ptimeb)
     /* Validate parameters */
     if (!ptimeb)
     {
+#if 0
         _invalid_parameter(0,
                            0,//__FUNCTION__,
                            _CRT_WIDE(__FILE__),
                            __LINE__,
                            0);
+#endif
         return EINVAL;
     }
 
index e48bcdc..5bd04f9 100644 (file)
@@ -82,7 +82,7 @@ _gmtime_worker(struct tm *ptm, __time64_t time, int do_dst)
     ptm->tm_mday = 1 + dayinyear - padays[month];
 
     /* Get weekday */
-    ptm->tm_wday = (days + 4) % 7;
+    ptm->tm_wday = (days + 1) % 7;
 
     /* Calculate hour and second in hour */
     ptm->tm_hour = secondinday / SECONDSPERHOUR;
index c10337a..035c6b8 100644 (file)
@@ -16,11 +16,13 @@ localtime_s(struct tm* _tm, const time_t *ptime)
     /* Validate parameters */
     if (!_tm || !ptime)
     {
+#if 0
         _invalid_parameter(NULL,
                            0,//__FUNCTION__, 
                            _CRT_WIDE(__FILE__), 
                            __LINE__, 
                            0);
+#endif
         return EINVAL;
     }