Changes in / [86e81a9:4cade47] in mainline


Ignore:
Location:
uspace/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/sys/time.h

    r86e81a9 r4cade47  
    11/*
    22 * Copyright (c) 2006 Ondrej Palkovsky
     3 * Copyright (c) 2011 Petr Koupy
     4 * Copyright (c) 2011 Jiri Zarevucky
    35 * All rights reserved.
    46 *
     
    4749
    4850struct tm {
    49         int tm_sec;       /* 0 - 59 */
    50         int tm_min;       /* 0 - 59 */
    51         int tm_hour;      /* 0 - 23 */
    52         int tm_mday;      /* 1 - 31 */
    53         int tm_mon;       /* 0 - 11 */
    54         int tm_year;      /* years since 1900 */
     51        int tm_sec;         /* Seconds [0,60]. */
     52        int tm_min;         /* Minutes [0,59]. */
     53        int tm_hour;        /* Hour [0,23]. */
     54        int tm_mday;        /* Day of month [1,31]. */
     55        int tm_mon;         /* Month of year [0,11]. */
     56        int tm_year;        /* Years since 1900. */
     57        int tm_wday;        /* Day of week [0,6] (Sunday = 0). */
     58        int tm_yday;        /* Day of year [0,365]. */
     59        int tm_isdst;       /* Daylight Savings flag. */
    5560};
    5661
  • uspace/lib/posix/time.c

    r86e81a9 r4cade47  
    200200 * @return Number of seconds since the epoch, not counting leap seconds.
    201201 */
    202 static time_t _secs_since_epoch(const struct posix_tm *tm)
     202static time_t _secs_since_epoch(const struct tm *tm)
    203203{
    204204        return _days_since_epoch(tm->tm_year, tm->tm_mon, tm->tm_mday) *
     
    229229 * @return 0 on success, -1 on overflow
    230230 */
    231 static int _normalize_time(struct posix_tm *tm, time_t sec_add)
     231static int _normalize_time(struct tm *tm, time_t sec_add)
    232232{
    233233        // TODO: DST correction
     
    324324 * @return Week-based year.
    325325 */
    326 static int _wbyear(const struct posix_tm *tm)
     326static int _wbyear(const struct tm *tm)
    327327{
    328328        int day = tm->tm_yday - _wbyear_offset(tm->tm_year);
     
    347347 * @return The week number (0 - 53).
    348348 */
    349 static int _sun_week_number(const struct posix_tm *tm)
     349static int _sun_week_number(const struct tm *tm)
    350350{
    351351        int first_day = (7 - _day_of_week(tm->tm_year, 0, 1)) % 7;
     
    363363 * @return The week number (1 - 53).
    364364 */
    365 static int _iso_week_number(const struct posix_tm *tm)
     365static int _iso_week_number(const struct tm *tm)
    366366{
    367367        int day = tm->tm_yday - _wbyear_offset(tm->tm_year);
     
    386386 * @return The week number (0 - 53).
    387387 */
    388 static int _mon_week_number(const struct posix_tm *tm)
     388static int _mon_week_number(const struct tm *tm)
    389389{
    390390        int first_day = (1 - _day_of_week(tm->tm_year, 0, 1)) % 7;
     
    430430 * @return time_t representation of the time, undefined value on overflow.
    431431 */
    432 time_t posix_mktime(struct posix_tm *tm)
     432time_t posix_mktime(struct tm *tm)
    433433{
    434434        // TODO: take DST flag into account
     
    445445 * @return Normalized broken-down time in UTC, NULL on overflow.
    446446 */
    447 struct posix_tm *posix_gmtime(const time_t *timer)
     447struct tm *posix_gmtime(const time_t *timer)
    448448{
    449449        assert(timer != NULL);
    450450
    451         static struct posix_tm result;
     451        static struct tm result;
    452452        return posix_gmtime_r(timer, &result);
    453453}
     
    460460 * @return Value of result on success, NULL on overflow.
    461461 */
    462 struct posix_tm *posix_gmtime_r(const time_t *restrict timer,
    463     struct posix_tm *restrict result)
     462struct tm *posix_gmtime_r(const time_t *restrict timer,
     463    struct tm *restrict result)
    464464{
    465465        assert(timer != NULL);
     
    488488 * @return Normalized broken-down time in local timezone, NULL on overflow.
    489489 */
    490 struct posix_tm *posix_localtime(const time_t *timer)
    491 {
    492         static struct posix_tm result;
     490struct tm *posix_localtime(const time_t *timer)
     491{
     492        static struct tm result;
    493493        return posix_localtime_r(timer, &result);
    494494}
     
    501501 * @return Value of result on success, NULL on overflow.
    502502 */
    503 struct posix_tm *posix_localtime_r(const time_t *restrict timer,
    504     struct posix_tm *restrict result)
     503struct tm *posix_localtime_r(const time_t *restrict timer,
     504    struct tm *restrict result)
    505505{
    506506        // TODO: deal with timezone
     
    516516 * @return Pointer to a statically allocated string.
    517517 */
    518 char *posix_asctime(const struct posix_tm *timeptr)
     518char *posix_asctime(const struct tm *timeptr)
    519519{
    520520        static char buf[ASCTIME_BUF_LEN];
     
    531531 * @return Value of buf.
    532532 */
    533 char *posix_asctime_r(const struct posix_tm *restrict timeptr,
     533char *posix_asctime_r(const struct tm *restrict timeptr,
    534534    char *restrict buf)
    535535{
     
    563563char *posix_ctime(const time_t *timer)
    564564{
    565         struct posix_tm *loctime = posix_localtime(timer);
     565        struct tm *loctime = posix_localtime(timer);
    566566        if (loctime == NULL) {
    567567                return NULL;
     
    580580char *posix_ctime_r(const time_t *timer, char *buf)
    581581{
    582         struct posix_tm loctime;
     582        struct tm loctime;
    583583        if (posix_localtime_r(timer, &loctime) == NULL) {
    584584                return NULL;
     
    598598 */
    599599size_t posix_strftime(char *restrict s, size_t maxsize,
    600     const char *restrict format, const struct posix_tm *restrict tm)
     600    const char *restrict format, const struct tm *restrict tm)
    601601{
    602602        assert(s != NULL);
  • uspace/lib/posix/time.h

    r86e81a9 r4cade47  
    6969#define CLOCK_REALTIME ((posix_clockid_t) 0)
    7070
    71 struct posix_tm {
    72         int tm_sec;         /* Seconds [0,60]. */
    73         int tm_min;         /* Minutes [0,59]. */
    74         int tm_hour;        /* Hour [0,23]. */
    75         int tm_mday;        /* Day of month [1,31]. */
    76         int tm_mon;         /* Month of year [0,11]. */
    77         int tm_year;        /* Years since 1900. */
    78         int tm_wday;        /* Day of week [0,6] (Sunday = 0). */
    79         int tm_yday;        /* Day of year [0,365]. */
    80         int tm_isdst;       /* Daylight Savings flag. */
    81 };
    82 
    8371struct posix_timespec {
    8472        time_t tv_sec; /* Seconds. */
     
    10391
    10492/* Broken-down Time */
    105 extern time_t posix_mktime(struct posix_tm *tm);
    106 extern struct posix_tm *posix_gmtime(const time_t *timer);
    107 extern struct posix_tm *posix_gmtime_r(const time_t *restrict timer,
    108     struct posix_tm *restrict result);
    109 extern struct posix_tm *posix_localtime(const time_t *timer);
    110 extern struct posix_tm *posix_localtime_r(const time_t *restrict timer,
    111     struct posix_tm *restrict result);
     93extern time_t posix_mktime(struct tm *tm);
     94extern struct tm *posix_gmtime(const time_t *timer);
     95extern struct tm *posix_gmtime_r(const time_t *restrict timer,
     96    struct tm *restrict result);
     97extern struct tm *posix_localtime(const time_t *timer);
     98extern struct tm *posix_localtime_r(const time_t *restrict timer,
     99    struct tm *restrict result);
    112100
    113101/* Formatting Calendar Time */
    114 extern char *posix_asctime(const struct posix_tm *timeptr);
    115 extern char *posix_asctime_r(const struct posix_tm *restrict timeptr,
     102extern char *posix_asctime(const struct tm *timeptr);
     103extern char *posix_asctime_r(const struct tm *restrict timeptr,
    116104    char *restrict buf);
    117105extern char *posix_ctime(const time_t *timer);
    118106extern char *posix_ctime_r(const time_t *timer, char *buf);
    119107extern size_t posix_strftime(char *restrict s, size_t maxsize,
    120     const char *restrict format, const struct posix_tm *restrict tm);
     108    const char *restrict format, const struct tm *restrict tm);
    121109
    122110/* Clocks */
     
    134122
    135123#ifndef LIBPOSIX_INTERNAL
    136         #define tm posix_tm
    137124        #define timespec posix_timespec
    138125        #define itimerspec posix_itimerspec
Note: See TracChangeset for help on using the changeset viewer.