Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f6cb995 in mainline for uspace/lib/c/generic/time.c


Ignore:
Timestamp:
2012-04-23T22:23:05Z (10 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master
Children:
56b308e
Parents:
8219eb9
Message:

libc: move localtime() from libposix to libc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/time.c

    r8219eb9 rf6cb995  
    798798
    799799        return &result;
    800 
    801800}
    802801
     
    833832}
    834833
     834/**
     835 * Converts a time value to a broken-down local time.
     836 *
     837 * @param timer Time to convert.
     838 * @return Normalized broken-down time in local timezone, NULL on overflow.
     839 */
     840struct tm *localtime(const time_t *timer)
     841{
     842        // TODO: deal with timezone
     843        // currently assumes system and all times are in GMT
     844
     845        static struct tm result;
     846
     847        /* Set result to epoch. */
     848        result.tm_sec = 0;
     849        result.tm_min = 0;
     850        result.tm_hour = 0;
     851        result.tm_mday = 1;
     852        result.tm_mon = 0;
     853        result.tm_year = 70; /* 1970 */
     854
     855        if (_normalize_time(&result, *timer) == -1) {
     856                errno = EOVERFLOW;
     857                return NULL;
     858        }
     859
     860        return &result;
     861}
    835862
    836863/** @}
Note: See TracChangeset for help on using the changeset viewer.