mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
libs/libc/time/lib_gmtimer.c: Spurious reorganization of a loop to work around and ZDD-II internal compiler error. Might be a little bigger now, but is also probably a more structured use of C.
This commit is contained in:
@@ -188,33 +188,33 @@ static void clock_utc2calendar(time_t days, FAR int *year, FAR int *month,
|
||||
days -= value * (4 * 365 + 1); /* Remaining days */
|
||||
value <<= 2; /* Years since the epoch */
|
||||
|
||||
/* Then we will brute force the next 0-3 years */
|
||||
/* Then we will brute force the next 0-3 years
|
||||
*
|
||||
* Is this year a leap year? (we'll need this later too)
|
||||
*/
|
||||
|
||||
for (; ; )
|
||||
leapyear = clock_isleapyear(value + 1970);
|
||||
|
||||
/* Get the number of days in the year */
|
||||
|
||||
tmp = (leapyear ? 366 : 365);
|
||||
|
||||
/* Do we have that many days left to account for? */
|
||||
|
||||
while (days >= tmp)
|
||||
{
|
||||
/* Is this year a leap year (we'll need this later too) */
|
||||
/* Yes.. bump up the year and subtract the number of days in the year */
|
||||
|
||||
value++;
|
||||
days -= tmp;
|
||||
|
||||
/* Is the next year a leap year? */
|
||||
|
||||
leapyear = clock_isleapyear(value + 1970);
|
||||
|
||||
/* Get the number of days in the year */
|
||||
/* Get the number of days in the next year */
|
||||
|
||||
tmp = (leapyear ? 366 : 365);
|
||||
|
||||
/* Do we have that many days? */
|
||||
|
||||
if (days >= tmp)
|
||||
{
|
||||
/* Yes.. bump up the year */
|
||||
|
||||
value++;
|
||||
days -= tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Nope... then go handle months */
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point, value has the year and days has number days into this
|
||||
|
||||
Reference in New Issue
Block a user