Changes in uspace/lib/posix/time.c [f8b6d34c:86e81a9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/time.c
rf8b6d34c r86e81a9 200 200 * @return Number of seconds since the epoch, not counting leap seconds. 201 201 */ 202 static time_t _secs_since_epoch(const struct tm *tm)202 static time_t _secs_since_epoch(const struct posix_tm *tm) 203 203 { 204 204 return _days_since_epoch(tm->tm_year, tm->tm_mon, tm->tm_mday) * … … 229 229 * @return 0 on success, -1 on overflow 230 230 */ 231 static int _normalize_time(struct tm *tm, time_t sec_add)231 static int _normalize_time(struct posix_tm *tm, time_t sec_add) 232 232 { 233 233 // TODO: DST correction … … 324 324 * @return Week-based year. 325 325 */ 326 static int _wbyear(const struct tm *tm)326 static int _wbyear(const struct posix_tm *tm) 327 327 { 328 328 int day = tm->tm_yday - _wbyear_offset(tm->tm_year); … … 347 347 * @return The week number (0 - 53). 348 348 */ 349 static int _sun_week_number(const struct tm *tm)349 static int _sun_week_number(const struct posix_tm *tm) 350 350 { 351 351 int first_day = (7 - _day_of_week(tm->tm_year, 0, 1)) % 7; … … 363 363 * @return The week number (1 - 53). 364 364 */ 365 static int _iso_week_number(const struct tm *tm)365 static int _iso_week_number(const struct posix_tm *tm) 366 366 { 367 367 int day = tm->tm_yday - _wbyear_offset(tm->tm_year); … … 386 386 * @return The week number (0 - 53). 387 387 */ 388 static int _mon_week_number(const struct tm *tm)388 static int _mon_week_number(const struct posix_tm *tm) 389 389 { 390 390 int first_day = (1 - _day_of_week(tm->tm_year, 0, 1)) % 7; … … 430 430 * @return time_t representation of the time, undefined value on overflow. 431 431 */ 432 time_t posix_mktime(struct tm *tm)432 time_t posix_mktime(struct posix_tm *tm) 433 433 { 434 434 // TODO: take DST flag into account … … 445 445 * @return Normalized broken-down time in UTC, NULL on overflow. 446 446 */ 447 struct tm *posix_gmtime(const time_t *timer)447 struct posix_tm *posix_gmtime(const time_t *timer) 448 448 { 449 449 assert(timer != NULL); 450 450 451 static struct tm result;451 static struct posix_tm result; 452 452 return posix_gmtime_r(timer, &result); 453 453 } … … 460 460 * @return Value of result on success, NULL on overflow. 461 461 */ 462 struct tm *posix_gmtime_r(const time_t *restrict timer,463 struct tm *restrict result)462 struct posix_tm *posix_gmtime_r(const time_t *restrict timer, 463 struct posix_tm *restrict result) 464 464 { 465 465 assert(timer != NULL); … … 488 488 * @return Normalized broken-down time in local timezone, NULL on overflow. 489 489 */ 490 struct tm *posix_localtime(const time_t *timer)491 { 492 static struct tm result;490 struct posix_tm *posix_localtime(const time_t *timer) 491 { 492 static struct posix_tm result; 493 493 return posix_localtime_r(timer, &result); 494 494 } … … 501 501 * @return Value of result on success, NULL on overflow. 502 502 */ 503 struct tm *posix_localtime_r(const time_t *restrict timer,504 struct tm *restrict result)503 struct posix_tm *posix_localtime_r(const time_t *restrict timer, 504 struct posix_tm *restrict result) 505 505 { 506 506 // TODO: deal with timezone … … 516 516 * @return Pointer to a statically allocated string. 517 517 */ 518 char *posix_asctime(const struct tm *timeptr)518 char *posix_asctime(const struct posix_tm *timeptr) 519 519 { 520 520 static char buf[ASCTIME_BUF_LEN]; … … 531 531 * @return Value of buf. 532 532 */ 533 char *posix_asctime_r(const struct tm *restrict timeptr,533 char *posix_asctime_r(const struct posix_tm *restrict timeptr, 534 534 char *restrict buf) 535 535 { … … 563 563 char *posix_ctime(const time_t *timer) 564 564 { 565 struct tm *loctime = posix_localtime(timer);565 struct posix_tm *loctime = posix_localtime(timer); 566 566 if (loctime == NULL) { 567 567 return NULL; … … 580 580 char *posix_ctime_r(const time_t *timer, char *buf) 581 581 { 582 struct tm loctime;582 struct posix_tm loctime; 583 583 if (posix_localtime_r(timer, &loctime) == NULL) { 584 584 return NULL; … … 598 598 */ 599 599 size_t posix_strftime(char *restrict s, size_t maxsize, 600 const char *restrict format, const struct tm *restrict tm)600 const char *restrict format, const struct posix_tm *restrict tm) 601 601 { 602 602 assert(s != NULL);
Note:
See TracChangeset
for help on using the changeset viewer.