...
Code Block | ||
---|---|---|
| ||
final static int ORIGIN_YEAR = 1980; public void zune_nce1(long days){ = /* Number of days since January 1, 1980 */ int year = ORIGIN_YEAR; /* ... */ while (days > 365) { if (IsLeapYear(year)) { if (days > 366) { days -= 366; year += 1; } } } else { days -= 365; year += 1; } } } |
The ConvertDays
method in the real-time clock (RTC) routines for the MC13783 PMIC RTC takes the number of days since January 1, 1980, and computes the correct year and number of days since January 1 of the correct year.
...
Code Block | ||
---|---|---|
| ||
final static int ORIGIN_YEAR = 1980; public void zune_cs1(long days){ = /* Number of days since January 1, 1980 */ int year = ORIGINYEARORIGIN_YEAR; /* ... */ int daysThisYear = (IsLeapYear(year) ? 366 : 365); while (days > daysThisYear) { days -= daysThisYear; year += 1; daysThisYear = (IsLeapYear(year) ? 366 : 365); } } |
This compliant solution is for illustrative purposes and is not necessarily the solution implemented by Microsoft.
...