Datasheet
The C and C++ Libraries
4-38 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0067D
4.6.8 _get_lc_time()
_get_lc_time()
must return a pointer to a
__lc_time_blk
structure. Use the macros in
Example 4-8 to create the structure.
Example 4-8 Time structure
__LC_TIME_DEF(lctime_c, "C",
"Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat",
"Sunday\0xxx" "Monday\0xxx" "Tuesday\0xx" "Wednesday\0"
"Thursday\0x" "Friday\0xxx" "Saturday\0",
"Jan\0Feb\0Mar\0Apr\0May\0Jun\0Jul\0Aug\0Sep\0Oct\0Nov\0Dec",
"January\0xx" "February\0x" "March\0xxxx" "April\0xxxx"
"May\0xxxxxx" "June\0xxxxx" "July\0xxxxx" "August\0xxx"
"September\0" "October\0xx" "November\0x" "December\0",
"AM", "PM",
"%x %X", "%d %b %Y", "%H:%M:%S")
__LC_TIME_DEF(lctime_fr, "fr",
"dim\0lun\0mar\0mer\0jeu\0ven\0sam",
"dimanche\0" "lundi\0xxx" "mardi\0xxx" "mercredi\0"
"jeudi\0xxx" "vendredi\0" "samedi\0x",
"jan\0xfev\0xmars\0avr\0xmai\0xjuin\0"
"juil\0aout\0sep\0xoct\0xnov\0xdec\0",
"janvier\0xx" "fevrier\0xx" "mars\0xxxxx" "avril\0xxxx"
"mai\0xxxxxx" "juin\0xxxxx" "juillet\0xx" "aout\0xxxxx"
"septembre\0" "octobre\0xx" "novembre\0x" "decembre\0",
"AM", "PM", "%A, %d %B %Y, %X", "%d.%m.%y", "%H:%M:%S")
__LC_INDEX_END(lctime_dummy)
void const *_get_lc_time(void const *null, char const *name) {
return _findlocale(&lctime_c_index, name);
}
void test_lc_time(void) {
struct tm tm;
char timestr[256];
tm.tm_sec = 13;
tm.tm_min = 13;
tm.tm_hour = 23;
tm.tm_mday = 12;
tm.tm_mon = 1;
tm.tm_year = 98;
tm.tm_wday = 4;
tm.tm_yday = 42;
tm.tm_isdst = 0;
EQS(setlocale(LC_TIME, NULL), "C"); /* verify starting point */
strftime(timestr, sizeof(timestr), "%c", &tm);
EQS(timestr, "12 Feb 1998 23:13:13");
EQI(!setlocale(LC_TIME, "fr"), 0); /* setlocale should work */
EQS(setlocale(LC_TIME, NULL), "fr");