Changeset f6cb995 in mainline
- Timestamp:
- 2012-04-23T22:23:05Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 56b308e
- Parents:
- 8219eb9
- Location:
- uspace/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/time.c
r8219eb9 rf6cb995 798 798 799 799 return &result; 800 801 800 } 802 801 … … 833 832 } 834 833 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 */ 840 struct 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 } 835 862 836 863 /** @} -
uspace/lib/c/include/sys/time.h
r8219eb9 rf6cb995 82 82 extern struct tm *gmtime(const time_t *timer); 83 83 extern char *asctime(const struct tm *timeptr); 84 extern struct tm *localtime(const time_t *timer); 84 85 extern size_t strftime(char *restrict s, size_t maxsize, 85 86 const char *restrict format, const struct tm *restrict tm); -
uspace/lib/posix/time.c
r8219eb9 rf6cb995 353 353 /** 354 354 * Converts a time value to a broken-down local time. 355 *356 * @param timer Time to convert.357 * @return Normalized broken-down time in local timezone, NULL on overflow.358 */359 struct tm *posix_localtime(const time_t *timer)360 {361 static struct tm result;362 return posix_localtime_r(timer, &result);363 }364 365 /**366 * Converts a time value to a broken-down local time.367 355 * 368 356 * @param timer Time to convert. … … 419 407 char *posix_ctime(const time_t *timer) 420 408 { 421 struct tm *loctime = posix_localtime(timer);409 struct tm *loctime = localtime(timer); 422 410 if (loctime == NULL) { 423 411 return NULL; -
uspace/lib/posix/time.h
r8219eb9 rf6cb995 90 90 extern struct tm *posix_gmtime_r(const time_t *restrict timer, 91 91 struct tm *restrict result); 92 extern struct tm *posix_localtime(const time_t *timer);93 92 extern struct tm *posix_localtime_r(const time_t *restrict timer, 94 93 struct tm *restrict result); … … 126 125 127 126 #define gmtime_r posix_gmtime_r 128 #define localtime posix_localtime129 127 #define localtime_r posix_localtime_r 130 128
Note:
See TracChangeset
for help on using the changeset viewer.