kern
diff src/klibc/time.c @ 38:e6f75f91e606
- added makefile pattern to produce assembly output from c source files.
- removed a commented out previous version of the gmtime_r function in klibc/time.c
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 10 Jun 2011 23:19:25 +0300 |
parents | 2c401f69128e |
children | 92297f65aaef |
line diff
1.1 --- a/src/klibc/time.c Fri Jun 10 19:54:47 2011 +0300 1.2 +++ b/src/klibc/time.c Fri Jun 10 23:19:25 2011 +0300 1.3 @@ -69,37 +69,35 @@ 1.4 1.5 struct tm *gmtime_r(time_t *tp, struct tm *tm) 1.6 { 1.7 - int yrsec, yrdays, monsec, leap, day, num_days = 0; 1.8 - int year = 1970; 1.9 - time_t t = *tp; 1.10 + int year, days, leap, yrdays; 1.11 + time_t t; 1.12 1.13 - while(t >= (yrsec = (yrdays = YEARDAYS(year)) * DAYSEC)) { 1.14 - t -= yrsec; 1.15 + year = 1970; 1.16 + days = *tp / DAYSEC; 1.17 + t = *tp % DAYSEC; 1.18 + 1.19 + tm->tm_wday = (days + 4) % 7; 1.20 + 1.21 + while(days >= (yrdays = YEARDAYS(year))) { 1.22 + days -= yrdays; 1.23 year++; 1.24 - num_days += yrdays; 1.25 } 1.26 tm->tm_year = year - 1900; 1.27 1.28 leap = is_leap_year(year); 1.29 tm->tm_mon = 0; 1.30 - while(t >= (monsec = mdays[leap][tm->tm_mon] * DAYSEC)) { 1.31 - num_days += mdays[leap][tm->tm_mon++]; 1.32 - t -= monsec; 1.33 + while(days >= mdays[leap][tm->tm_mon]) { 1.34 + days -= mdays[leap][tm->tm_mon++]; 1.35 } 1.36 1.37 - day = t / DAYSEC; 1.38 - tm->tm_mday = day + 1; 1.39 - t %= DAYSEC; 1.40 + tm->tm_mday = days + 1; 1.41 1.42 tm->tm_hour = t / HOURSEC; 1.43 t %= HOURSEC; 1.44 - 1.45 tm->tm_min = t / MINSEC; 1.46 tm->tm_sec = t % MINSEC; 1.47 1.48 - num_days += day; 1.49 - tm->tm_wday = (num_days + 4) % 7; 1.50 - tm->tm_yday = day_of_year(year, tm->tm_mon, day); 1.51 + tm->tm_yday = day_of_year(year, tm->tm_mon, days); 1.52 return tm; 1.53 } 1.54