Changeset 80d3f846 in mainline
- Timestamp:
- 2012-04-15T15:24:03Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f6af126
- Parents:
- a8a0d43
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-rtc.c
ra8a0d43 r80d3f846 92 92 static int rtc_tm_sanity_check(struct tm *t); 93 93 static void rtc_register_write(rtc_t *rtc, int reg, int data); 94 94 static bool is_leap_year(int year); 95 96 static int days_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 95 97 96 98 static ddf_dev_ops_t rtc_dev_ops; … … 429 431 rtc_tm_sanity_check(struct tm *t) 430 432 { 433 int ndays; 434 431 435 if (t->tm_sec < 0 || t->tm_sec > 59) 432 436 return EINVAL; … … 442 446 return EINVAL; 443 447 444 /* XXX Some months have less than 31 days... */ 448 if (t->tm_mon == 1/* FEB */ && is_leap_year(t->tm_year)) 449 ndays = 29; 450 else 451 ndays = days_month[t->tm_mon]; 452 453 if (t->tm_mday > ndays) 454 return EINVAL; 455 445 456 return EOK; 457 } 458 459 /** Check if a year is a leap year 460 * 461 * @param year The year to check 462 * 463 * @return true if it is a leap year, false otherwise 464 */ 465 static bool 466 is_leap_year(int year) 467 { 468 bool r = false; 469 470 if (year % 4 == 0) { 471 if (year % 100 == 0) 472 r = year % 400 == 0; 473 else 474 r = true; 475 } 476 477 return r; 446 478 } 447 479
Note:
See TracChangeset
for help on using the changeset viewer.