hrev47941 adds 1 changeset to branch 'master' old head: cedd1e158b898956252bfb746bff6bc072e7e8b9 new head: 0a925409bc43bc95879729a8bf2cb611f9c9c2f2 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=0a92540+%5Ecedd1e1 ---------------------------------------------------------------------------- 0a92540: Adjust all BDateFormat callers again. [ Adrien Destugues <pulkomandy@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47941 Commit: 0a925409bc43bc95879729a8bf2cb611f9c9c2f2 URL: http://cgit.haiku-os.org/haiku/commit/?id=0a92540 Author: Adrien Destugues <pulkomandy@xxxxxxxxx> Date: Wed Oct 1 14:35:34 2014 UTC ---------------------------------------------------------------------------- 10 files changed, 30 insertions(+), 16 deletions(-) src/apps/deskbar/TimeView.cpp | 3 ++- src/apps/deskbar/TimeView.h | 4 +++- src/kits/shared/CalendarView.cpp | 2 +- src/kits/tracker/WidgetAttributeText.cpp | 4 ++-- src/kits/tracker/WidgetAttributeText.h | 5 +++-- src/preferences/locale/FormatSettingsView.cpp | 12 ++++++++---- src/preferences/time/DateTimeEdit.cpp | 8 ++++---- src/preferences/time/DateTimeEdit.h | 2 ++ src/preferences/time/TimeZoneListView.cpp | 2 +- src/preferences/time/TimeZoneListView.h | 4 ++++ ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 9bbb9d8..1e89ee5 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -422,7 +422,7 @@ TTimeView::GetCurrentDate() { char tmp[sizeof(fCurrentDateStr)]; - BDateFormat::Default()->Format(tmp, sizeof(fCurrentDateStr), fCurrentTime, + fDateFormat.Format(tmp, sizeof(fCurrentDateStr), fCurrentTime, B_FULL_DATE_FORMAT); // remove leading 0 from date when month is less than 10 (MM/DD/YY) @@ -489,6 +489,7 @@ void TTimeView::Update() { fLocale = *BLocale::Default(); + fDateFormat.SetLocale(fLocale); GetCurrentTime(); GetCurrentDate(); diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index ba823dd..5328585 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -36,9 +36,10 @@ All rights reserved. #define TIME_VIEW_H -#include <OS.h> +#include <DateFormat.h> #include <Locale.h> #include <Messenger.h> +#include <OS.h> #include <View.h> @@ -148,6 +149,7 @@ private: // For date and time localization purposes BLocale fLocale; + BDateFormat fDateFormat; }; diff --git a/src/kits/shared/CalendarView.cpp b/src/kits/shared/CalendarView.cpp index 087b5bf..0ebc021 100644 --- a/src/kits/shared/CalendarView.cpp +++ b/src/kits/shared/CalendarView.cpp @@ -705,7 +705,7 @@ BCalendarView::_InitObject() { fDate = BDate::CurrentDate(B_LOCAL_TIME); - BDateFormat::Default()->GetStartOfWeek((BWeekday*)&fStartOfWeek); + BDateFormat().GetStartOfWeek((BWeekday*)&fStartOfWeek); _SetupDayNames(); _SetupDayNumbers(); diff --git a/src/kits/tracker/WidgetAttributeText.cpp b/src/kits/tracker/WidgetAttributeText.cpp index 365fe88..cb15844 100644 --- a/src/kits/tracker/WidgetAttributeText.cpp +++ b/src/kits/tracker/WidgetAttributeText.cpp @@ -178,7 +178,7 @@ TruncStringBase(BString* outString, const char* inString, int32 length, BFont font; view->GetFont(&font); - font.GetTruncatedStrings(source, 1, truncMode, width, results); + font.GetTruncatedStrings(source, 1, truncMode, width, results); outString->UnlockBuffer(); } @@ -214,7 +214,7 @@ TruncTimeBase(BString* outString, int64 value, const View* view, float width) } if (resultWidth > width - && BDateFormat::Default()->Format(date, timeValue, + && BDateFormat().Format(date, timeValue, B_SHORT_DATE_FORMAT) == B_OK) { resultWidth = view->StringWidth(date.String(), date.Length()); } diff --git a/src/kits/tracker/WidgetAttributeText.h b/src/kits/tracker/WidgetAttributeText.h index 3e02943..bdc5c96 100644 --- a/src/kits/tracker/WidgetAttributeText.h +++ b/src/kits/tracker/WidgetAttributeText.h @@ -35,6 +35,7 @@ All rights reserved. #define _TEXT_WIDGET_ATTRIBUTE_H +#include <DateFormat.h> #include <String.h> #include "TrackerSettings.h" @@ -129,8 +130,8 @@ protected: float fTruncatedWidth; bool fDirty; // if true, need to recalculate text next time we try to use it - bool fValueIsDefined; - BString fText; + bool fValueIsDefined; + BString fText; // holds the truncated text, fit to the parameters passed in // in the last FittingText call }; diff --git a/src/preferences/locale/FormatSettingsView.cpp b/src/preferences/locale/FormatSettingsView.cpp index d7fee35..a0c1dc2 100644 --- a/src/preferences/locale/FormatSettingsView.cpp +++ b/src/preferences/locale/FormatSettingsView.cpp @@ -361,16 +361,20 @@ FormatSettingsView::_UpdateExamples() time_t timeValue = (time_t)time(NULL); BString result; - BDateFormat::Default()->Format(result, timeValue, B_FULL_DATE_FORMAT); + // Do NOT make this a class member. We do want to recreate it everytime, as + // to get the updated settings from the locale roster. + BDateFormat dateFormat; + + dateFormat.Format(result, timeValue, B_FULL_DATE_FORMAT); fFullDateExampleView->SetText(result); - BDateFormat::Default()->Format(result, timeValue, B_LONG_DATE_FORMAT); + dateFormat.Format(result, timeValue, B_LONG_DATE_FORMAT); fLongDateExampleView->SetText(result); - BDateFormat::Default()->Format(result, timeValue, B_MEDIUM_DATE_FORMAT); + dateFormat.Format(result, timeValue, B_MEDIUM_DATE_FORMAT); fMediumDateExampleView->SetText(result); - BDateFormat::Default()->Format(result, timeValue, B_SHORT_DATE_FORMAT); + dateFormat.Format(result, timeValue, B_SHORT_DATE_FORMAT); fShortDateExampleView->SetText(result); BLocale::Default()->FormatTime(&result, timeValue, B_FULL_TIME_FORMAT); diff --git a/src/preferences/time/DateTimeEdit.cpp b/src/preferences/time/DateTimeEdit.cpp index b54af09..0391755 100644 --- a/src/preferences/time/DateTimeEdit.cpp +++ b/src/preferences/time/DateTimeEdit.cpp @@ -623,15 +623,15 @@ TDateEdit::_UpdateFields() free(fFieldPositions); fFieldPositions = NULL; } - BDateFormat::Default()->Format(fText, fFieldPositions, fFieldPosCount, - time, B_SHORT_DATE_FORMAT); + + fDateFormat.Format(fText, fFieldPositions, fFieldPosCount, time, + B_SHORT_DATE_FORMAT); if (fFields != NULL) { free(fFields); fFields = NULL; } - BDateFormat::Default()->GetFields(fFields, fFieldCount, - B_SHORT_DATE_FORMAT); + fDateFormat.GetFields(fFields, fFieldCount, B_SHORT_DATE_FORMAT); } diff --git a/src/preferences/time/DateTimeEdit.h b/src/preferences/time/DateTimeEdit.h index 7cb7c60..2a0d62d 100644 --- a/src/preferences/time/DateTimeEdit.h +++ b/src/preferences/time/DateTimeEdit.h @@ -12,6 +12,7 @@ #define _DATE_TIME_EDIT_H +#include <DateFormat.h> #include <DateTime.h> #include <Locale.h> #include <String.h> @@ -94,6 +95,7 @@ private: int32 _SectionValue(int32 index) const; BDate fDate; + BDateFormat fDateFormat; bigtime_t fLastKeyDownTime; int32 fLastKeyDownInt; diff --git a/src/preferences/time/TimeZoneListView.cpp b/src/preferences/time/TimeZoneListView.cpp index e690201..ccc942f 100644 --- a/src/preferences/time/TimeZoneListView.cpp +++ b/src/preferences/time/TimeZoneListView.cpp @@ -51,7 +51,7 @@ TimeZoneListView::GetToolTipAt(BPoint point, BToolTip** _tip) &item->TimeZone()); BString dateInTimeZone; - BDateFormat::Default()->Format(dateInTimeZone, now, B_SHORT_DATE_FORMAT, + fDateFormat.Format(dateInTimeZone, now, B_SHORT_DATE_FORMAT, &item->TimeZone()); BString toolTip = item->Text(); diff --git a/src/preferences/time/TimeZoneListView.h b/src/preferences/time/TimeZoneListView.h index 87c529d..fbd9466 100644 --- a/src/preferences/time/TimeZoneListView.h +++ b/src/preferences/time/TimeZoneListView.h @@ -9,6 +9,7 @@ #define _TIME_ZONE_LIST_VIEW_H +#include <DateFormat.h> #include <OutlineListView.h> @@ -19,6 +20,9 @@ public: protected: virtual bool GetToolTipAt(BPoint point, BToolTip** _tip); + +private: + BDateFormat fDateFormat; };