Adjust all BDateFormat callers again.

This commit is contained in:
Adrien Destugues
2014-10-01 16:35:34 +02:00
parent cedd1e158b
commit 0a925409bc
10 changed files with 30 additions and 16 deletions
+2 -1
View File
@@ -422,7 +422,7 @@ TTimeView::GetCurrentDate()
{ {
char tmp[sizeof(fCurrentDateStr)]; char tmp[sizeof(fCurrentDateStr)];
BDateFormat::Default()->Format(tmp, sizeof(fCurrentDateStr), fCurrentTime, fDateFormat.Format(tmp, sizeof(fCurrentDateStr), fCurrentTime,
B_FULL_DATE_FORMAT); B_FULL_DATE_FORMAT);
// remove leading 0 from date when month is less than 10 (MM/DD/YY) // remove leading 0 from date when month is less than 10 (MM/DD/YY)
@@ -489,6 +489,7 @@ void
TTimeView::Update() TTimeView::Update()
{ {
fLocale = *BLocale::Default(); fLocale = *BLocale::Default();
fDateFormat.SetLocale(fLocale);
GetCurrentTime(); GetCurrentTime();
GetCurrentDate(); GetCurrentDate();
+3 -1
View File
@@ -36,9 +36,10 @@ All rights reserved.
#define TIME_VIEW_H #define TIME_VIEW_H
#include <OS.h> #include <DateFormat.h>
#include <Locale.h> #include <Locale.h>
#include <Messenger.h> #include <Messenger.h>
#include <OS.h>
#include <View.h> #include <View.h>
@@ -148,6 +149,7 @@ private:
// For date and time localization purposes // For date and time localization purposes
BLocale fLocale; BLocale fLocale;
BDateFormat fDateFormat;
}; };
+1 -1
View File
@@ -705,7 +705,7 @@ BCalendarView::_InitObject()
{ {
fDate = BDate::CurrentDate(B_LOCAL_TIME); fDate = BDate::CurrentDate(B_LOCAL_TIME);
BDateFormat::Default()->GetStartOfWeek((BWeekday*)&fStartOfWeek); BDateFormat().GetStartOfWeek((BWeekday*)&fStartOfWeek);
_SetupDayNames(); _SetupDayNames();
_SetupDayNumbers(); _SetupDayNumbers();
+2 -2
View File
@@ -178,7 +178,7 @@ TruncStringBase(BString* outString, const char* inString, int32 length,
BFont font; BFont font;
view->GetFont(&font); view->GetFont(&font);
font.GetTruncatedStrings(source, 1, truncMode, width, results); font.GetTruncatedStrings(source, 1, truncMode, width, results);
outString->UnlockBuffer(); outString->UnlockBuffer();
} }
@@ -214,7 +214,7 @@ TruncTimeBase(BString* outString, int64 value, const View* view, float width)
} }
if (resultWidth > width if (resultWidth > width
&& BDateFormat::Default()->Format(date, timeValue, && BDateFormat().Format(date, timeValue,
B_SHORT_DATE_FORMAT) == B_OK) { B_SHORT_DATE_FORMAT) == B_OK) {
resultWidth = view->StringWidth(date.String(), date.Length()); resultWidth = view->StringWidth(date.String(), date.Length());
} }
+3 -2
View File
@@ -35,6 +35,7 @@ All rights reserved.
#define _TEXT_WIDGET_ATTRIBUTE_H #define _TEXT_WIDGET_ATTRIBUTE_H
#include <DateFormat.h>
#include <String.h> #include <String.h>
#include "TrackerSettings.h" #include "TrackerSettings.h"
@@ -129,8 +130,8 @@ protected:
float fTruncatedWidth; float fTruncatedWidth;
bool fDirty; bool fDirty;
// if true, need to recalculate text next time we try to use it // if true, need to recalculate text next time we try to use it
bool fValueIsDefined; bool fValueIsDefined;
BString fText; BString fText;
// holds the truncated text, fit to the parameters passed in // holds the truncated text, fit to the parameters passed in
// in the last FittingText call // in the last FittingText call
}; };
@@ -361,16 +361,20 @@ FormatSettingsView::_UpdateExamples()
time_t timeValue = (time_t)time(NULL); time_t timeValue = (time_t)time(NULL);
BString result; 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); fFullDateExampleView->SetText(result);
BDateFormat::Default()->Format(result, timeValue, B_LONG_DATE_FORMAT); dateFormat.Format(result, timeValue, B_LONG_DATE_FORMAT);
fLongDateExampleView->SetText(result); fLongDateExampleView->SetText(result);
BDateFormat::Default()->Format(result, timeValue, B_MEDIUM_DATE_FORMAT); dateFormat.Format(result, timeValue, B_MEDIUM_DATE_FORMAT);
fMediumDateExampleView->SetText(result); fMediumDateExampleView->SetText(result);
BDateFormat::Default()->Format(result, timeValue, B_SHORT_DATE_FORMAT); dateFormat.Format(result, timeValue, B_SHORT_DATE_FORMAT);
fShortDateExampleView->SetText(result); fShortDateExampleView->SetText(result);
BLocale::Default()->FormatTime(&result, timeValue, B_FULL_TIME_FORMAT); BLocale::Default()->FormatTime(&result, timeValue, B_FULL_TIME_FORMAT);
+4 -4
View File
@@ -623,15 +623,15 @@ TDateEdit::_UpdateFields()
free(fFieldPositions); free(fFieldPositions);
fFieldPositions = NULL; 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) { if (fFields != NULL) {
free(fFields); free(fFields);
fFields = NULL; fFields = NULL;
} }
BDateFormat::Default()->GetFields(fFields, fFieldCount, fDateFormat.GetFields(fFields, fFieldCount, B_SHORT_DATE_FORMAT);
B_SHORT_DATE_FORMAT);
} }
+2
View File
@@ -12,6 +12,7 @@
#define _DATE_TIME_EDIT_H #define _DATE_TIME_EDIT_H
#include <DateFormat.h>
#include <DateTime.h> #include <DateTime.h>
#include <Locale.h> #include <Locale.h>
#include <String.h> #include <String.h>
@@ -94,6 +95,7 @@ private:
int32 _SectionValue(int32 index) const; int32 _SectionValue(int32 index) const;
BDate fDate; BDate fDate;
BDateFormat fDateFormat;
bigtime_t fLastKeyDownTime; bigtime_t fLastKeyDownTime;
int32 fLastKeyDownInt; int32 fLastKeyDownInt;
+1 -1
View File
@@ -51,7 +51,7 @@ TimeZoneListView::GetToolTipAt(BPoint point, BToolTip** _tip)
&item->TimeZone()); &item->TimeZone());
BString dateInTimeZone; BString dateInTimeZone;
BDateFormat::Default()->Format(dateInTimeZone, now, B_SHORT_DATE_FORMAT, fDateFormat.Format(dateInTimeZone, now, B_SHORT_DATE_FORMAT,
&item->TimeZone()); &item->TimeZone());
BString toolTip = item->Text(); BString toolTip = item->Text();
+4
View File
@@ -9,6 +9,7 @@
#define _TIME_ZONE_LIST_VIEW_H #define _TIME_ZONE_LIST_VIEW_H
#include <DateFormat.h>
#include <OutlineListView.h> #include <OutlineListView.h>
@@ -19,6 +20,9 @@ public:
protected: protected:
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip); virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
private:
BDateFormat fDateFormat;
}; };