summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-03-02 22:10:04 +0000
committerache <ache@FreeBSD.org>2001-03-02 22:10:04 +0000
commit1ad9d0ac29a0c4abee8ea6c1f7e1ca00c01b69c0 (patch)
tree0d18d6fef085d49ef004f8a345fd0cfe0f8a4953 /lib/libc
parent021d152d846c8f073aaea8a609dbeaebb29a7e66 (diff)
downloadFreeBSD-src-1ad9d0ac29a0c4abee8ea6c1f7e1ca00c01b69c0.zip
FreeBSD-src-1ad9d0ac29a0c4abee8ea6c1f7e1ca00c01b69c0.tar.gz
Implement ampm_fmt (%r) per POSIX
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdtime/strftime.c2
-rw-r--r--lib/libc/stdtime/strptime.c2
-rw-r--r--lib/libc/stdtime/timelocal.c22
-rw-r--r--lib/libc/stdtime/timelocal.h5
4 files changed, 22 insertions, 9 deletions
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c
index 23120f2..e54ea89 100644
--- a/lib/libc/stdtime/strftime.c
+++ b/lib/libc/stdtime/strftime.c
@@ -234,7 +234,7 @@ label:
pt = _fmt("%H:%M", t, pt, ptlim);
continue;
case 'r':
- pt = _fmt("%I:%M:%S %p", t, pt, ptlim);
+ pt = _fmt(tptr->ampm_fmt, t, pt, ptlim);
continue;
case 'S':
pt = _conv(t->tm_sec, "%02d", pt, ptlim);
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index ee32651..57c5da1 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -181,7 +181,7 @@ label:
break;
case 'r':
- buf = _strptime(buf, "%I:%M:%S %p", tm);
+ buf = _strptime(buf, tptr->ampm_fmt, tm);
if (buf == 0)
return 0;
break;
diff --git a/lib/libc/stdtime/timelocal.c b/lib/libc/stdtime/timelocal.c
index ab89789..1caed7d 100644
--- a/lib/libc/stdtime/timelocal.c
+++ b/lib/libc/stdtime/timelocal.c
@@ -27,6 +27,8 @@
* $FreeBSD$
*/
+#include <stddef.h>
+
#include "ldpart.h"
#include "timelocal.h"
@@ -34,7 +36,9 @@ static struct lc_time_T _time_locale;
static int _time_using_locale;
static char * time_locale_buf;
-#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
+#define LCTIME_SIZE_FULL (sizeof(struct lc_time_T) / sizeof(char *))
+#define LCTIME_SIZE_MIN \
+ (offsetof(struct lc_time_T, ampm_fmt) / sizeof(char *))
static const struct lc_time_T _C_time_locale = {
{
@@ -90,7 +94,12 @@ static const struct lc_time_T _C_time_locale = {
/* EF_fmt
** To determine long months / day order
*/
- "%B %e"
+ "%B %e",
+
+ /* ampm_fmt
+ ** To determine 12-hour clock format time (empty, if N/A)
+ */
+ "%I:%M:%S %p"
};
struct lc_time_T *
@@ -105,12 +114,15 @@ __time_load_locale(const char *name) {
int ret;
+ _time_locale.ampm_fmt = _C_time_locale.ampm_fmt;
+
ret = __part_load_locale(name, &_time_using_locale,
- time_locale_buf, "LC_TIME", LCTIME_SIZE, LCTIME_SIZE,
+ time_locale_buf, "LC_TIME",
+ LCTIME_SIZE_FULL, LCTIME_SIZE_MIN,
(const char **)&_time_locale);
/* XXX: always overwrite for ctime format parsing compatibility */
- if (ret == 0 && _time_using_locale)
- _time_locale.c_fmt = _C_time_locale.c_fmt;
+ _time_locale.c_fmt = _C_time_locale.c_fmt;
+
return (ret);
}
diff --git a/lib/libc/stdtime/timelocal.h b/lib/libc/stdtime/timelocal.h
index 06d650a..7dbfdcf 100644
--- a/lib/libc/stdtime/timelocal.h
+++ b/lib/libc/stdtime/timelocal.h
@@ -45,8 +45,9 @@ struct lc_time_T {
const char * pm;
const char * date_fmt;
const char * alt_month[12];
- const char * Ef_fmt;
- const char * EF_fmt;
+ const char * Ef_fmt;
+ const char * EF_fmt;
+ const char * ampm_fmt;
};
struct lc_time_T * __get_current_time_locale(void);
OpenPOWER on IntegriCloud