BDate: do not use strftime
Using BDateFimeFormat avoids going through libroot and up again to ICU throuhg the locale add-on. Moreover, it uses the Locale settings directly instead of relying on the LC_* environment variables. Fixes day names in Web+ history menu always showing in english. Tnaks to Oco for noticing! Change-Id: I0c7f321a6147e8f5ab31f82de836c5ad23bb321b Reviewed-on: https://review.haiku-os.org/650 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
c30513840a
commit
ffd9d565d2
@ -13,6 +13,9 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <DateFormat.h>
|
||||
#include <Locale.h>
|
||||
#include <LocaleRoster.h>
|
||||
#include <Message.h>
|
||||
|
||||
|
||||
@ -1018,14 +1021,13 @@ BDate::LongDayName(int32 day)
|
||||
if (day < 1 || day > 7)
|
||||
return BString();
|
||||
|
||||
tm tm_struct;
|
||||
memset(&tm_struct, 0, sizeof(tm));
|
||||
tm_struct.tm_wday = day == 7 ? 0 : day;
|
||||
const BLocale* locale = BLocaleRoster::Default()->GetDefaultLocale();
|
||||
BDateFormat format(locale);
|
||||
BString out;
|
||||
if (format.GetDayName(day, out, B_LONG_DATE_FORMAT) != B_OK)
|
||||
return BString();
|
||||
|
||||
char buffer[256];
|
||||
strftime(buffer, sizeof(buffer), "%A", &tm_struct);
|
||||
|
||||
return BString(buffer);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@ -1049,14 +1051,13 @@ BDate::LongMonthName(int32 month)
|
||||
if (month < 1 || month > 12)
|
||||
return BString();
|
||||
|
||||
tm tm_struct;
|
||||
memset(&tm_struct, 0, sizeof(tm));
|
||||
tm_struct.tm_mon = month - 1;
|
||||
const BLocale* locale = BLocaleRoster::Default()->GetDefaultLocale();
|
||||
BDateFormat format(locale);
|
||||
BString out;
|
||||
if (format.GetMonthName(month, out, B_LONG_DATE_FORMAT) != B_OK)
|
||||
return BString();
|
||||
|
||||
char buffer[256];
|
||||
strftime(buffer, sizeof(buffer), "%B", &tm_struct);
|
||||
|
||||
return BString(buffer);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user