[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2358] Reverted month_length() back to using the 'knuc
From: |
Mike Rice |
Subject: |
[avr-libc-commit] [2358] Reverted month_length() back to using the 'knuckles' algorithm. |
Date: |
Tue, 23 Apr 2013 22:30:21 +0000 |
Revision: 2358
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2358
Author: swfltek
Date: 2013-04-23 22:30:20 +0000 (Tue, 23 Apr 2013)
Log Message:
-----------
Reverted month_length() back to using the 'knuckles' algorithm. Easier to
understand, and a couple words less FLASH.
Modified Paths:
--------------
trunk/avr-libc/libc/time/month_length.c
Modified: trunk/avr-libc/libc/time/month_length.c
===================================================================
--- trunk/avr-libc/libc/time/month_length.c 2013-04-21 16:25:30 UTC (rev
2357)
+++ trunk/avr-libc/libc/time/month_length.c 2013-04-23 22:30:20 UTC (rev
2358)
@@ -38,7 +38,11 @@
uint8_t
month_length(int year, uint8_t month)
{
- if (month == 2) return 28 + is_leap_year(year);
+ if (month == 2)
+ return 28 + is_leap_year(year);
- return 30 + ((month + month / 8) & 1);
+ /* 'knuckles' algorithm */
+ if (month > 7)
+ month++;
+ return 30 + (month & 1);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2358] Reverted month_length() back to using the 'knuckles' algorithm.,
Mike Rice <=