Changeset 8219eb9 in mainline
- Timestamp:
- 2012-04-23T22:14:32Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f6cb995
- Parents:
- 5b3394c
- Location:
- uspace/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/time.c
r5b3394c r8219eb9 48 48 #include <stdio.h> 49 49 #include <ctype.h> 50 51 #define ASCTIME_BUF_LEN 26 50 52 51 53 /** Pointer to kernel shared variables with time */ … … 799 801 } 800 802 803 /** 804 * Converts broken-down time to a string in format 805 * "Sun Jan 1 00:00:00 1970\n". (Obsolete) 806 * 807 * @param timeptr Broken-down time structure. 808 * @return Pointer to a statically allocated string. 809 */ 810 char *asctime(const struct tm *timeptr) 811 { 812 static char buf[ASCTIME_BUF_LEN]; 813 814 assert(timeptr != NULL); 815 816 static const char *wday[] = { 817 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" 818 }; 819 static const char *mon[] = { 820 "Jan", "Feb", "Mar", "Apr", "May", "Jun", 821 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 822 }; 823 824 snprintf(buf, ASCTIME_BUF_LEN, "%s %s %2d %02d:%02d:%02d %d\n", 825 wday[timeptr->tm_wday], 826 mon[timeptr->tm_mon], 827 timeptr->tm_mday, timeptr->tm_hour, 828 timeptr->tm_min, timeptr->tm_sec, 829 1900 + timeptr->tm_year); 830 831 return buf; 832 833 } 834 801 835 802 836 /** @} -
uspace/lib/c/include/sys/time.h
r5b3394c r8219eb9 41 41 42 42 #define DST_NONE 0 43 #define ASCTIME_BUF_LEN 26 43 44 44 45 typedef long time_t; … … 80 81 extern time_t mktime(struct tm *tm); 81 82 extern struct tm *gmtime(const time_t *timer); 83 extern char *asctime(const struct tm *timeptr); 82 84 extern size_t strftime(char *restrict s, size_t maxsize, 83 85 const char *restrict format, const struct tm *restrict tm); -
uspace/lib/posix/time.c
r5b3394c r8219eb9 383 383 * 384 384 * @param timeptr Broken-down time structure. 385 * @return Pointer to a statically allocated string.386 */387 char *posix_asctime(const struct tm *timeptr)388 {389 static char buf[ASCTIME_BUF_LEN];390 return posix_asctime_r(timeptr, buf);391 }392 393 /**394 * Converts broken-down time to a string in format395 * "Sun Jan 1 00:00:00 1970\n". (Obsolete)396 *397 * @param timeptr Broken-down time structure.398 385 * @param buf Buffer to store string to, must be at least ASCTIME_BUF_LEN 399 386 * bytes long. … … 436 423 return NULL; 437 424 } 438 return posix_asctime(loctime);425 return asctime(loctime); 439 426 } 440 427 -
uspace/lib/posix/time.h
r5b3394c r8219eb9 63 63 #endif 64 64 65 #undef ASCTIME_BUF_LEN66 #define ASCTIME_BUF_LEN 2667 68 65 #undef CLOCK_REALTIME 69 66 #define CLOCK_REALTIME ((posix_clockid_t) 0) … … 98 95 99 96 /* Formatting Calendar Time */ 100 extern char *posix_asctime(const struct tm *timeptr);101 97 extern char *posix_asctime_r(const struct tm *restrict timeptr, 102 98 char *restrict buf); … … 133 129 #define localtime_r posix_localtime_r 134 130 135 #define asctime posix_asctime136 131 #define asctime_r posix_asctime_r 137 132 #define ctime posix_ctime
Note:
See TracChangeset
for help on using the changeset viewer.