* as/link/lkar.h: sgetl and sputl are independent of endianness
[fw/sdcc] / device / lib / time.c
old mode 100755 (executable)
new mode 100644 (file)
index 8cb00d1..8266ab9
@@ -69,18 +69,21 @@ static char ascTimeBuffer[32];
 static void CheckTime(struct tm *timeptr) {
     // we could do some normalization here, e.g.
     // change 40 october to 9 november
+    #if !__TIME_UNSIGNED
     if (timeptr->tm_sec<0) timeptr->tm_sec=0;
-    else if (timeptr->tm_sec>59) timeptr->tm_sec=59;
     if (timeptr->tm_min<0) timeptr->tm_min=0;
-    else if (timeptr->tm_min>59) timeptr->tm_min=59;
     if (timeptr->tm_hour<0) timeptr->tm_hour=0;
-    else if (timeptr->tm_hour>23) timeptr->tm_hour=23;
     if (timeptr->tm_wday<0) timeptr->tm_wday=0;
-    else if (timeptr->tm_wday>6) timeptr->tm_wday=6;
+    if (timeptr->tm_mon<0) timeptr->tm_mon=0;
+    #endif
+    
+    if (timeptr->tm_sec>59) timeptr->tm_sec=59;
+    if (timeptr->tm_min>59) timeptr->tm_min=59;
+    if (timeptr->tm_hour>23) timeptr->tm_hour=23;
+    if (timeptr->tm_wday>6) timeptr->tm_wday=6;
     if (timeptr->tm_mday<1) timeptr->tm_mday=1;
     else if (timeptr->tm_mday>31) timeptr->tm_mday=31;
-    if (timeptr->tm_mon<0) timeptr->tm_mon=0;
-    else if (timeptr->tm_mon>11) timeptr->tm_mon=11;
+    if (timeptr->tm_mon>11) timeptr->tm_mon=11;
     if (timeptr->tm_year<0) timeptr->tm_year=0;
 }
 
@@ -194,8 +197,8 @@ time_t mktime(struct tm *timeptr) {
       }
     }
 
-    seconds+= timeptr->tm_mday-1*60*60*24L;
-    seconds+= timeptr->tm_hour*60*60;
+    seconds+= (timeptr->tm_mday-1)*60*60*24L;
+    seconds+= timeptr->tm_hour*60*60L;
     seconds+= timeptr->tm_min*60;
     seconds+= timeptr->tm_sec;
     return seconds;