diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-07 20:10:31 +0100 |
| commit | fc00c656c96528112d05cf0edf8631bd5eaea446 (patch) | |
| tree | a6e0e6c588191a8bd1c64afc3b7a258e3e66c236 /lib/libc/time/asctime.c | |
Add build system scaffolding and libc headers
Diffstat (limited to 'lib/libc/time/asctime.c')
| -rw-r--r-- | lib/libc/time/asctime.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/libc/time/asctime.c b/lib/libc/time/asctime.c new file mode 100644 index 00000000..54729a77 --- /dev/null +++ b/lib/libc/time/asctime.c @@ -0,0 +1,19 @@ +#include <time.h> +#include <stdio.h> + +char *asctime(const struct tm *timeptr) +{ + static char wday_name[7][3] = { "Sun", "Mon", "Tue", "Wed", + "Thu", "Fri", "Sat" }; + static char mon_name[12][3] = { "Jan", "Feb", "Mar", "Apr", + "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec" }; + static char result[26]; + + snprintf(result, sizeof(result), "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", + wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon], + timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min, + timeptr->tm_sec, 1900 + timeptr->tm_year); + + return result; +} |
