diff options
author | ache <ache@FreeBSD.org> | 2001-03-02 22:10:04 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-03-02 22:10:04 +0000 |
commit | 1ad9d0ac29a0c4abee8ea6c1f7e1ca00c01b69c0 (patch) | |
tree | 0d18d6fef085d49ef004f8a345fd0cfe0f8a4953 /lib/libc/stdtime/timelocal.c | |
parent | 021d152d846c8f073aaea8a609dbeaebb29a7e66 (diff) | |
download | FreeBSD-src-1ad9d0ac29a0c4abee8ea6c1f7e1ca00c01b69c0.zip FreeBSD-src-1ad9d0ac29a0c4abee8ea6c1f7e1ca00c01b69c0.tar.gz |
Implement ampm_fmt (%r) per POSIX
Diffstat (limited to 'lib/libc/stdtime/timelocal.c')
-rw-r--r-- | lib/libc/stdtime/timelocal.c | 22 |
1 files changed, 17 insertions, 5 deletions
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); } |