2 * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
3 * Copyright (c) 1997 FreeBSD Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
31 #include "setlocale.h"
33 #define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
35 const struct lc_time_T _C_time_locale
= {
37 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
38 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
40 "January", "February", "March", "April", "May", "June",
41 "July", "August", "September", "October", "November", "December"
43 "Sun", "Mon", "Tue", "Wed",
46 "Sunday", "Monday", "Tuesday", "Wednesday",
47 "Thursday", "Friday", "Saturday"
55 * Since the C language standard calls for
56 * "date, using locale's date format," anything goes.
57 * Using just numbers (as here) makes Quakers happier;
58 * it's also compatible with SVR4.
65 "%a %b %e %H:%M:%S %Y",
71 "%a %b %e %H:%M:%S %Z %Y",
74 * Standalone months forms for %OB
77 "January", "February", "March", "April", "May", "June",
78 "July", "August", "September", "October", "November", "December"
82 * Month / day order in dates
87 * To determine 12-hour clock format time (empty, if N/A)
92 * Era. This and the following entries are used if the alternative
93 * date format is specified in strftime
98 * Era date format used with the %Ex
103 * Era date/time format (%Ec)
108 * Era time format (%EX)
113 * Alternate digits used if %O format prefix is specified
116 #ifdef __HAVE_LOCALE_INFO_EXTENDED__
117 , "ASCII", /* codeset */
119 L
"Jan", L
"Feb", L
"Mar", L
"Apr", L
"May", L
"Jun",
120 L
"Jul", L
"Aug", L
"Sep", L
"Oct", L
"Nov", L
"Dec"
122 L
"January", L
"February", L
"March", L
"April", L
"May", L
"June",
123 L
"July", L
"August", L
"September", L
"October", L
"November",
126 L
"Sun", L
"Mon", L
"Tue", L
"Wed",
127 L
"Thu", L
"Fri", L
"Sat"
129 L
"Sunday", L
"Monday", L
"Tuesday", L
"Wednesday",
130 L
"Thursday", L
"Friday", L
"Saturday"
134 L
"%a %b %e %H:%M:%S %Y",
136 L
"%a %b %e %H:%M:%S %Z %Y",
147 __time_load_locale (struct __locale_t
*locale
, const char *name
,
148 void *f_wctomb
, const char *charset
)
154 #ifdef __HAVE_LOCALE_INFO__
156 extern int __set_lc_time_from_win (const char *, const struct lc_time_T
*,
157 struct lc_time_T
*, char **, void *,
159 ret
= __set_lc_time_from_win (name
, &_C_time_locale
, &ti
, &bufp
,
161 /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */
164 struct lc_time_T
*tip
= NULL
;
168 tip
= (struct lc_time_T
*) calloc (1, sizeof *tip
);
176 struct __lc_cats tmp
= locale
->lc_cat
[LC_TIME
];
177 locale
->lc_cat
[LC_TIME
].ptr
= ret
== 0 ? &_C_time_locale
: tip
;
178 locale
->lc_cat
[LC_TIME
].buf
= bufp
;
179 /* If buf is not NULL, both pointers have been alloc'ed */
182 free ((void *) tmp
.ptr
);
190 #endif /* __HAVE_LOCALE_INFO__ */