提交 e74ca7fc 编写于 作者: O onelife.real

minilibc:

Fix a bug in time functions


git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1520 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 6904f495
...@@ -70,7 +70,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r) ...@@ -70,7 +70,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *r)
struct tm* localtime_r(const time_t* t, struct tm* r) struct tm* localtime_r(const time_t* t, struct tm* r)
{ {
time_t tmp; time_t tmp;
struct timezone tz; struct timezone tz = {0};
gettimeofday(0, &tz); gettimeofday(0, &tz);
timezone = tz.tz_minuteswest * 60L; timezone = tz.tz_minuteswest * 60L;
tmp = *t + timezone; tmp = *t + timezone;
...@@ -134,8 +134,9 @@ time_t timegm(struct tm * const t) ...@@ -134,8 +134,9 @@ time_t timegm(struct tm * const t)
This is not intuitive. Most mktime implementations do not support This is not intuitive. Most mktime implementations do not support
dates after 2059, anyway, so we might leave this out for it's dates after 2059, anyway, so we might leave this out for it's
bloat. */ bloat. */
if ((years -= 131) >= 0) if (years >= 131)
{ {
years -= 131;
years /= 100; years /= 100;
day -= (years >> 2) * 3 + 1; day -= (years >> 2) * 3 + 1;
if ((years &= 3) == 3) if ((years &= 3) == 3)
...@@ -159,7 +160,7 @@ time_t timegm(struct tm * const t) ...@@ -159,7 +160,7 @@ time_t timegm(struct tm * const t)
time_t mktime(register struct tm* const t) time_t mktime(register struct tm* const t)
{ {
time_t x = timegm(t); time_t x = timegm(t);
struct timezone tz; struct timezone tz = {0};
gettimeofday(0, &tz); gettimeofday(0, &tz);
timezone = tz.tz_minuteswest * 60L; timezone = tz.tz_minuteswest * 60L;
x += timezone; x += timezone;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册