summaryrefslogtreecommitdiff
path: root/libc/misc/time/asc_conv.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-05-11 05:40:55 +0000
committerEric Andersen <andersen@codepoet.org>2002-05-11 05:40:55 +0000
commitfd15708e6476164990e7b364dc5b2aa1600f8e89 (patch)
tree7627bd8a8c546f2fafd99fb52c1f96fdf4b242ce /libc/misc/time/asc_conv.c
parenta4f07581502ee212aa45e7b0049fdd126dd10b40 (diff)
Begin the process of reworking the time functions for proper
time zone and locale support (in theory). More work is still needed. -Erik
Diffstat (limited to 'libc/misc/time/asc_conv.c')
-rw-r--r--libc/misc/time/asc_conv.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/libc/misc/time/asc_conv.c b/libc/misc/time/asc_conv.c
index 78339dd6c..f5ab0a615 100644
--- a/libc/misc/time/asc_conv.c
+++ b/libc/misc/time/asc_conv.c
@@ -1,4 +1,5 @@
+#include <features.h>
#include <time.h>
#include <string.h>
/*
@@ -16,29 +17,39 @@
*
* Also fixed day conversion ... ANSI says no leading 0.
*
+ * Modified Erik Andersen May 2002
+ * Changed to optionally support real locales.
+ *
*/
-void __asctime(buffer, ptm)
-register char *buffer;
-struct tm *ptm;
+#ifdef __UCLIBC_HAS_LOCALE__
+/* This is defined in locale/C-time.c in the GNU libc. */
+extern const struct locale_data _nl_C_LC_TIME;
+extern const unsigned short int __mon_yday[2][13];
+# define __ab_weekday_name \
+ (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABDAY_1)].string)
+# define __ab_month_name (&_nl_C_LC_TIME.values[_NL_ITEM_INDEX (ABMON_1)].string)
+#else
+extern char const __ab_weekday_name[][4];
+extern char const __ab_month_name[][4];
+#endif
+
+void __asctime(register char *buffer, struct tm *ptm)
{
- static const char days[] = "SunMonTueWedThuFriSat";
- static const char mons[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
- /* 012345678901234567890123456 */
- static const char template[] = "Err Err 00 00:00:00 0000\n";
- int tm_field[4];
- int tmp, i;
char *p;
+ int tmp, i, tm_field[4];
+ /* 012345678901234567890123456 */
+ static const char template[] = "??? ??? 00 00:00:00 0000\n";
/* Since we need memcpy below, use it here instead of strcpy. */
memcpy(buffer, template, sizeof(template));
if ((ptm->tm_wday >= 0) && (ptm->tm_wday <= 6)) {
- memcpy(buffer, days + 3 * (ptm->tm_wday), 3);
+ memcpy(buffer, __ab_weekday_name[ptm->tm_wday], 3);
}
if ((ptm->tm_mon >= 0) && (ptm->tm_mon <= 11)) {
- memcpy(buffer + 4, mons + 3 * (ptm->tm_mon), 3);
+ memcpy(buffer + 4, __ab_month_name[ptm->tm_mon], 3);
}
tm_field[0] = ptm->tm_mday;