diff --git a/headers/os/locale/Locale.h b/headers/os/locale/Locale.h index be7663c4eb..febdc25325 100644 --- a/headers/os/locale/Locale.h +++ b/headers/os/locale/Locale.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011, Haiku, Inc. + * Copyright 2003-2012, Haiku, Inc. * Distributed under the terms of the MIT License. */ #ifndef _B_LOCALE_H_ @@ -119,9 +119,14 @@ public: // has been implemented! ssize_t FormatTime(char* string, size_t maxSize, time_t time, BTimeFormatStyle style) const; + ssize_t FormatTime(char* string, size_t maxSize, + time_t time, BString format) const; status_t FormatTime(BString* string, time_t time, BTimeFormatStyle style, const BTimeZone* timeZone = NULL) const; + status_t FormatTime(BString* string, time_t time, + BString format, + const BTimeZone* timeZone) const; status_t FormatTime(BString* string, int*& fieldPositions, int& fieldCount, time_t time, BTimeFormatStyle style) const; diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp index 1b8d752501..e6ffbdf7c2 100644 --- a/src/apps/deskbar/BarApp.cpp +++ b/src/apps/deskbar/BarApp.cpp @@ -33,7 +33,9 @@ holders. All rights reserved. */ -#include + +#include "BarApp.h" + #include #include #include @@ -42,6 +44,7 @@ All rights reserved. #include #include #include +#include #include #include #include @@ -54,13 +57,14 @@ All rights reserved. #include "icons.h" #include "tracker_private.h" -#include "BarApp.h" #include "BarView.h" #include "BarWindow.h" +#include "PreferencesWindow.h" #include "DeskbarUtils.h" #include "FSUtils.h" #include "PublicCommands.h" #include "ResourceSet.h" +#include "StatusView.h" #include "Switcher.h" #include "Utilities.h" @@ -97,6 +101,7 @@ TBarApp::TBarApp() InitIconPreloader(); fBarWindow = new TBarWindow(); + fBarView = fBarWindow->BarView(); be_roster->StartWatching(this); @@ -127,7 +132,7 @@ TBarApp::TBarApp() // Call UpdatePlacement() after the window is shown because expanded apps // need to resize the window. if (fBarWindow->Lock()) { - BarView()->UpdatePlacement(); + fBarView->UpdatePlacement(); fBarWindow->Unlock(); } @@ -200,7 +205,9 @@ TBarApp::SaveSettings() storedSettings.AddFloat("width", fSettings.width); storedSettings.AddBool("showTime", fSettings.showTime); - storedSettings.AddBool("timeFormat", fSettings.timeFormat); + storedSettings.AddBool("showSeconds", fSettings.showSeconds); + storedSettings.AddBool("showDayOfWeek", fSettings.showDayOfWeek); + storedSettings.AddBool("showTimeZone", fSettings.showTimeZone); storedSettings.AddPoint("switcherLoc", fSettings.switcherLoc); storedSettings.AddInt32("recentAppsCount", fSettings.recentAppsCount); @@ -239,7 +246,9 @@ TBarApp::InitSettings() settings.left = false; settings.top = true; settings.showTime = true; - settings.timeFormat = B_SHORT_TIME_FORMAT; + settings.showSeconds = false; + settings.showDayOfWeek = false; + settings.showTimeZone = false; settings.state = kExpandoState; settings.width = 0; settings.switcherLoc = BPoint(5000, 5000); @@ -298,9 +307,17 @@ TBarApp::InitSettings() != B_OK) { settings.showTime = true; } - if (storedSettings.FindUInt32("timeFormat", &settings.timeFormat) + if (storedSettings.FindBool("showSeconds", &settings.showSeconds) != B_OK) { - settings.timeFormat = B_SHORT_TIME_FORMAT; + settings.showSeconds = false; + } + if (storedSettings.FindBool("showDayOfWeek", &settings.showDayOfWeek) + != B_OK) { + settings.showDayOfWeek = false; + } + if (storedSettings.FindBool("showTimeZone", &settings.showTimeZone) + != B_OK) { + settings.showTimeZone = false; } if (storedSettings.FindPoint("switcherLoc", &settings.switcherLoc) != B_OK) { @@ -494,7 +511,7 @@ TBarApp::MessageReceived(BMessage* message) !fSettings.autoRaise; fBarWindow->Lock(); - BarView()->UpdateEventMask(); + fBarView->UpdateEventMask(); fBarWindow->Unlock(); break; @@ -502,8 +519,8 @@ TBarApp::MessageReceived(BMessage* message) fSettings.autoHide = !fSettings.autoHide; fBarWindow->Lock(); - BarView()->UpdateEventMask(); - BarView()->HideDeskbar(fSettings.autoHide); + fBarView->UpdateEventMask(); + fBarView->HideDeskbar(fSettings.autoHide); fBarWindow->Unlock(); break; @@ -511,7 +528,7 @@ TBarApp::MessageReceived(BMessage* message) fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst; fBarWindow->Lock(); - BarView()->PlaceApplicationBar(); + fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -519,7 +536,7 @@ TBarApp::MessageReceived(BMessage* message) fSettings.sortRunningApps = !fSettings.sortRunningApps; fBarWindow->Lock(); - BarView()->PlaceApplicationBar(); + fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -535,7 +552,7 @@ TBarApp::MessageReceived(BMessage* message) fSettings.superExpando = !fSettings.superExpando; fBarWindow->Lock(); - BarView()->PlaceApplicationBar(); + fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -543,7 +560,7 @@ TBarApp::MessageReceived(BMessage* message) fSettings.expandNewTeams = !fSettings.expandNewTeams; fBarWindow->Lock(); - BarView()->PlaceApplicationBar(); + fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -551,7 +568,7 @@ TBarApp::MessageReceived(BMessage* message) fSettings.hideLabels = !fSettings.hideLabels; fBarWindow->Lock(); - BarView()->PlaceApplicationBar(); + fBarView->PlaceApplicationBar(); fBarWindow->Unlock(); break; @@ -571,14 +588,14 @@ TBarApp::MessageReceived(BMessage* message) ResizeTeamIcons(); - if (BarView()->MiniState()) + if (fBarView->MiniState()) break; fBarWindow->Lock(); - if (BarView()->Vertical()) - BarView()->PlaceApplicationBar(); + if (fBarView->Vertical()) + fBarView->PlaceApplicationBar(); else - BarView()->UpdatePlacement(); + fBarView->UpdatePlacement(); fBarWindow->Unlock(); break; @@ -761,7 +778,7 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref) sBarTeamInfoList.AddItem(barInfo); if (fSettings.expandNewTeams) - BarView()->AddExpandedItem(sig); + fBarView->AddExpandedItem(sig); int32 subsCount = sSubscribers.CountItems(); if (subsCount > 0) { diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h index 4871240059..626286bf38 100644 --- a/src/apps/deskbar/BarApp.h +++ b/src/apps/deskbar/BarApp.h @@ -37,11 +37,6 @@ All rights reserved. #include -#include -#include -#include "BarWindow.h" -#include "PreferencesWindow.h" - /* ------------------------------------ */ // Private app_server defines that I need to use @@ -51,20 +46,6 @@ All rights reserved. #define _STD_W_TYPE_ 0 -class BarTeamInfo { -public: - BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon, - char* name); - BarTeamInfo(const BarTeamInfo &info); - ~BarTeamInfo(); - - BList* teams; - uint32 flags; - char* sig; - BBitmap* icon; - char* name; -}; - const uint32 kWin95 = 'Bill'; const uint32 kAmiga = 'Ncro'; const uint32 kMac = 'WcOS'; @@ -76,14 +57,6 @@ const uint32 kAddTeam = 'AdTm'; const uint32 kRemoveTeam = 'RmTm'; const uint32 kRestart = 'Rtrt'; const uint32 kShutDown = 'ShDn'; -const uint32 kTrackerFirst = 'TkFt'; -const uint32 kSortRunningApps = 'SAps'; -const uint32 kSuperExpando = 'SprE'; -const uint32 kExpandNewTeams = 'ExTm'; -const uint32 kHideLabels = 'hLbs'; -const uint32 kResizeTeamIcons = 'RTIs'; -const uint32 kAutoRaise = 'AtRs'; -const uint32 kAutoHide = 'AtHd'; const uint32 kRestartTracker = 'Trak'; // from roster_private.h @@ -103,7 +76,9 @@ struct desk_settings { bool left; bool top; bool showTime; - uint32 timeFormat; + bool showSeconds; + bool showDayOfWeek; + bool showTimeZone; uint32 state; float width; BPoint switcherLoc; @@ -126,11 +101,28 @@ struct desk_settings { bool recentFoldersEnabled; }; - -class TBarView; class BFile; +class BList; +class BBitmap; +class PreferencesWindow; +class TBarView; +class TBarWindow; + + +class BarTeamInfo { +public: + BarTeamInfo(BList* teams, uint32 flags, char* sig, BBitmap* icon, + char* name); + BarTeamInfo(const BarTeamInfo &info); + ~BarTeamInfo(); + + BList* teams; + uint32 flags; + char* sig; + BBitmap* icon; + char* name; +}; -using namespace BPrivate; class TBarApp : public BApplication { public: @@ -141,12 +133,9 @@ class TBarApp : public BApplication { virtual void MessageReceived(BMessage* message); virtual void RefsReceived(BMessage* refs); - desk_settings* Settings() - { return &fSettings; } - TBarView* BarView() const - { return fBarWindow->BarView(); } - TBarWindow* BarWindow() const - { return fBarWindow; } + desk_settings* Settings() { return &fSettings; } + TBarView* BarView() const { return fBarView; } + TBarWindow* BarWindow() const { return fBarWindow; } static void Subscribe(const BMessenger &subscriber, BList*); static void Unsubscribe(const BMessenger &subscriber); @@ -165,6 +154,7 @@ class TBarApp : public BApplication { BRect IconRect(); TBarWindow* fBarWindow; + TBarView* fBarView; BMessenger fSwitcherMessenger; BMessenger fStatusViewMessenger; BFile* fSettingsFile; @@ -177,5 +167,5 @@ class TBarApp : public BApplication { static BList sSubscribers; }; -#endif // BAR_APP_H +#endif // BAR_APP_H diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h index 1fd309b838..22f4a6981f 100644 --- a/src/apps/deskbar/BarView.h +++ b/src/apps/deskbar/BarView.h @@ -36,12 +36,17 @@ All rights reserved. #ifndef BARVIEW_H #define BARVIEW_H + #include #include #include "NavMenu.h" #include "ObjectList.h" + +const uint32 kStateChanged = 'stch'; + + enum DeskbarShelf { B_DESKBAR_ANY_SHELF = 0, B_DESKBAR_TRAY = 1 @@ -53,6 +58,7 @@ enum { kFullState = 2 }; + const float kMiniHeight = 46.0f; const float kHModeHeight = 21.0f; const float kMenuBarHeight = 21.0f; @@ -60,6 +66,7 @@ const float kStatusHeight = 22.0f; const float kHiddenDimension = 1.0f; const float kMaxPreventHidingDist = 80.0f; + class BShelf; class TBarMenuBar; class TExpandoMenuBar; diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp index 45aa5910fa..e60a4de33e 100644 --- a/src/apps/deskbar/BarWindow.cpp +++ b/src/apps/deskbar/BarWindow.cpp @@ -39,6 +39,7 @@ All rights reserved. #include #include +#include #include #include #include diff --git a/src/apps/deskbar/BarWindow.h b/src/apps/deskbar/BarWindow.h index 958bdfa985..f3f8ccc1a4 100644 --- a/src/apps/deskbar/BarWindow.h +++ b/src/apps/deskbar/BarWindow.h @@ -88,7 +88,7 @@ private: bool _IsFocusMessage(BMessage* message); private: - static TDeskbarMenu* sDeskbarMenu; + static TDeskbarMenu* sDeskbarMenu; TBarView* fBarView; }; diff --git a/src/apps/deskbar/DeskbarMenu.cpp b/src/apps/deskbar/DeskbarMenu.cpp index e2b201689d..aebfcd138d 100644 --- a/src/apps/deskbar/DeskbarMenu.cpp +++ b/src/apps/deskbar/DeskbarMenu.cpp @@ -400,7 +400,9 @@ TDeskbarMenu::ResetTargets() case kShowHideTime: case kTimeIntervalChanged: - case kTimeFormatChanged: + case kShowSeconds: + case kShowDayOfWeek: + case kShowTimeZone: item->SetTarget(fBarView->fReplicantTray); break; } diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp index 244adddaa3..f2cbcd6d65 100644 --- a/src/apps/deskbar/ExpandoMenuBar.cpp +++ b/src/apps/deskbar/ExpandoMenuBar.cpp @@ -49,6 +49,7 @@ All rights reserved. #include "BarApp.h" #include "BarMenuTitle.h" #include "BarView.h" +#include "BarWindow.h" #include "DeskbarMenu.h" #include "DeskbarUtils.h" #include "ExpandoMenuBar.h" diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp index a7ff314f9f..6d777a89c3 100644 --- a/src/apps/deskbar/PreferencesWindow.cpp +++ b/src/apps/deskbar/PreferencesWindow.cpp @@ -3,6 +3,7 @@ * All Rights Reserved. Distributed under the terms of the MIT License. * * Authors: + * John Scipione, jscipione@gmail.com * Jonas Sundström, jonas@kirilla.com */ @@ -11,6 +12,8 @@ #include +#include +#include #include #include #include @@ -22,6 +25,7 @@ #include #include #include +#include #include #include "BarApp.h" @@ -91,22 +95,12 @@ PreferencesWindow::PreferencesWindow(BRect frame) fTimeInterval24HourRadioButton = new BRadioButton("time inteval", B_TRANSLATE("24 hour"), timeInterval24HoursMessage); - BMessage* timeFormatShortMessage = new BMessage(kTimeFormatChanged); - timeFormatShortMessage->AddUInt32("time format", B_SHORT_TIME_FORMAT); - fTimeFormatShortRadioButton = new BRadioButton("time format", - "Short", timeFormatShortMessage); - - BMessage* timeFormatMediumMessage = new BMessage(kTimeFormatChanged); - timeFormatMediumMessage->AddUInt32("time format", B_MEDIUM_TIME_FORMAT); - fTimeFormatMediumRadioButton = new BRadioButton("time format", - "Medium", timeFormatMediumMessage); - - BMessage* timeFormatLongMessage = new BMessage(kTimeFormatChanged); - timeFormatLongMessage->AddUInt32("time format", B_LONG_TIME_FORMAT); - fTimeFormatLongRadioButton = new BRadioButton("time format", - "Long", timeFormatLongMessage); - - _UpdateTimeFormatRadioButtonLabels(); + fShowSeconds = new BCheckBox(B_TRANSLATE("Show seconds"), + new BMessage(kShowSeconds)); + fShowDayOfWeek = new BCheckBox(B_TRANSLATE("Show day of week"), + new BMessage(kShowDayOfWeek)); + fShowTimeZone = new BCheckBox(B_TRANSLATE("Show time zone"), + new BMessage(kShowTimeZone)); // Get settings from BarApp TBarApp* barApp = static_cast(be_app); @@ -175,18 +169,18 @@ PreferencesWindow::PreferencesWindow(BRect frame) else fTimeInterval12HourRadioButton->SetValue(B_CONTROL_ON); - switch (settings->timeFormat) { - case B_LONG_TIME_FORMAT: - fTimeFormatLongRadioButton->SetValue(B_CONTROL_ON); - break; - case B_MEDIUM_TIME_FORMAT: - fTimeFormatMediumRadioButton->SetValue(B_CONTROL_ON); - break; - default: - fTimeFormatShortRadioButton->SetValue(B_CONTROL_ON); + TReplicantTray* replicantTray = barApp->BarView()->ReplicantTray(); + if (replicantTray->Time() != NULL) { + fShowSeconds->SetValue(replicantTray->Time()->ShowSeconds()); + fShowDayOfWeek->SetValue(replicantTray->Time()->ShowDayOfWeek()); + fShowTimeZone->SetValue(replicantTray->Time()->ShowTimeZone()); + } else { + fShowSeconds->SetValue(settings->showSeconds); + fShowDayOfWeek->SetValue(settings->showDayOfWeek); + fShowTimeZone->SetValue(settings->showTimeZone); } - _EnableDisableDependentItems(); + EnableDisableDependentItems(); // Targets fAppsSort->SetTarget(be_app); @@ -199,12 +193,12 @@ PreferencesWindow::PreferencesWindow(BRect frame) fWindowAutoRaise->SetTarget(be_app); fWindowAutoHide->SetTarget(be_app); - TReplicantTray* replicantTray = barApp->BarView()->fReplicantTray; fTimeInterval12HourRadioButton->SetTarget(replicantTray); fTimeInterval24HourRadioButton->SetTarget(replicantTray); - fTimeFormatShortRadioButton->SetTarget(replicantTray); - fTimeFormatMediumRadioButton->SetTarget(replicantTray); - fTimeFormatLongRadioButton->SetTarget(replicantTray); + + fShowSeconds->SetTarget(replicantTray); + fShowDayOfWeek->SetTarget(replicantTray); + fShowTimeZone->SetTarget(replicantTray); // Layout fMenuBox = new BBox("fMenuBox"); @@ -281,21 +275,6 @@ PreferencesWindow::PreferencesWindow(BRect frame) timeIntervalView->AddChild(fTimeInterval12HourRadioButton); timeIntervalView->AddChild(fTimeInterval24HourRadioButton); - BStringView* timeFormatLabel = new BStringView("format", - B_TRANSLATE("Format")); - timeFormatLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, - B_SIZE_UNSET)); - timeFormatLabel->SetLowColor((rgb_color){255, 255, 255, 255}); - - BGroupLayout* timeFormatLayout = new BGroupLayout(B_VERTICAL, 0); - timeFormatLayout->SetInsets(10, 0, 0, 0); - BView* timeFormatView = new BView("format", 0, timeFormatLayout); - timeFormatView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - timeFormatView->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - timeFormatView->AddChild(fTimeFormatShortRadioButton); - timeFormatView->AddChild(fTimeFormatMediumRadioButton); - timeFormatView->AddChild(fTimeFormatLongRadioButton); - view = BLayoutBuilder::Group<>() .AddGroup(B_VERTICAL, 10) .AddGroup(B_VERTICAL, 0) @@ -303,8 +282,9 @@ PreferencesWindow::PreferencesWindow(BRect frame) .Add(timeIntervalView) .End() .AddGroup(B_VERTICAL, 0) - .Add(timeFormatLabel) - .Add(timeFormatView) + .Add(fShowSeconds) + .Add(fShowDayOfWeek) + .Add(fShowTimeZone) .End() .AddGlue() .SetInsets(10, 10, 10, 10) @@ -328,7 +308,7 @@ PreferencesWindow::PreferencesWindow(BRect frame) PreferencesWindow::~PreferencesWindow() { - _UpdateRecentCounts(); + UpdateRecentCounts(); be_app->PostMessage(kConfigClose); } @@ -342,16 +322,16 @@ PreferencesWindow::MessageReceived(BMessage* message) break; case kUpdateRecentCounts: - _UpdateRecentCounts(); + UpdateRecentCounts(); break; case kSuperExpando: - _EnableDisableDependentItems(); + EnableDisableDependentItems(); be_app->PostMessage(message); break; case kStateChanged: - _EnableDisableDependentItems(); + EnableDisableDependentItems(); break; default: @@ -370,7 +350,7 @@ PreferencesWindow::WindowActivated(bool active) void -PreferencesWindow::_UpdateRecentCounts() +PreferencesWindow::UpdateRecentCounts() { BMessage message(kUpdateRecentCounts); @@ -388,12 +368,12 @@ PreferencesWindow::_UpdateRecentCounts() be_app->PostMessage(&message); - _EnableDisableDependentItems(); + EnableDisableDependentItems(); } void -PreferencesWindow::_EnableDisableDependentItems() +PreferencesWindow::EnableDisableDependentItems() { TBarApp* barApp = static_cast(be_app); if (barApp->BarView()->Vertical() @@ -415,20 +395,3 @@ PreferencesWindow::_EnableDisableDependentItems() fWindowAutoRaise->SetEnabled( fWindowAlwaysOnTop->Value() == B_CONTROL_OFF); } - - -void -PreferencesWindow::_UpdateTimeFormatRadioButtonLabels() -{ - time_t timeValue = (time_t)time(NULL); - BString result; - - BLocale::Default()->FormatTime(&result, timeValue, B_SHORT_TIME_FORMAT); - fTimeFormatShortRadioButton->SetLabel(result); - - BLocale::Default()->FormatTime(&result, timeValue, B_MEDIUM_TIME_FORMAT); - fTimeFormatMediumRadioButton->SetLabel(result); - - BLocale::Default()->FormatTime(&result, timeValue, B_LONG_TIME_FORMAT); - fTimeFormatLongRadioButton->SetLabel(result); -} diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h index 9bc9c533c7..1bf492cb55 100644 --- a/src/apps/deskbar/PreferencesWindow.h +++ b/src/apps/deskbar/PreferencesWindow.h @@ -6,22 +6,36 @@ #define _PREFERENCES_WINDOW_H -#include -#include -#include -#include -#include -#include -#include #include -const uint32 kConfigShow = 'show'; -const uint32 kConfigClose = 'canc'; -const uint32 kUpdateRecentCounts = 'upct'; -const uint32 kEditMenuInTracker = 'mtrk'; -const uint32 kStateChanged = 'stch'; +const uint32 kConfigShow = 'show'; +const uint32 kConfigClose = 'canc'; +const uint32 kUpdateRecentCounts = 'upct'; +const uint32 kEditMenuInTracker = 'mtrk'; +const uint32 kTrackerFirst = 'TkFt'; +const uint32 kSortRunningApps = 'SAps'; +const uint32 kSuperExpando = 'SprE'; +const uint32 kExpandNewTeams = 'ExTm'; +const uint32 kHideLabels = 'hLbs'; +const uint32 kResizeTeamIcons = 'RTIs'; +const uint32 kAutoRaise = 'AtRs'; +const uint32 kAutoHide = 'AtHd'; + +const uint32 kShowHideTime = 'ShTm'; +const uint32 kTimeIntervalChanged = 'TiCh'; +const uint32 kShowSeconds = 'SwSc'; +const uint32 kShowDayOfWeek = 'SwDw'; +const uint32 kShowTimeZone = 'SwTz'; + +class BBox; +class BButton; +class BCheckBox; +class BRadioButton; +class BSlider; +class BStringView; +class BTextControl; class PreferencesWindow : public BWindow { @@ -29,14 +43,13 @@ public: PreferencesWindow(BRect frame); ~PreferencesWindow(); - virtual void MessageReceived(BMessage* message); - virtual void WindowActivated(bool active); + virtual void MessageReceived(BMessage* message); + virtual void WindowActivated(bool active); + + void UpdateRecentCounts(); + void EnableDisableDependentItems(); private: - void _UpdateRecentCounts(); - void _EnableDisableDependentItems(); - void _UpdateTimeFormatRadioButtonLabels(); - BBox* fMenuBox; BBox* fAppsBox; BBox* fClockBox; @@ -61,14 +74,13 @@ private: BCheckBox* fWindowAutoRaise; BCheckBox* fWindowAutoHide; - BCheckBox* fShowTime; BRadioButton* fTimeInterval24HourRadioButton; BRadioButton* fTimeInterval12HourRadioButton; - BRadioButton* fTimeFormatLongRadioButton; - BRadioButton* fTimeFormatMediumRadioButton; - BRadioButton* fTimeFormatShortRadioButton; + BCheckBox* fShowSeconds; + BCheckBox* fShowDayOfWeek; + BCheckBox* fShowTimeZone; }; -#endif // _PREFERENCES_WINDOW_H +#endif // _PREFERENCES_WINDOW_H diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index faef6f2118..bd42de82d4 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -143,9 +143,15 @@ TReplicantTray::TReplicantTray(TBarView* parent, bool vertical) fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth; } + BFormattingConventions conventions; + BLocale::Default()->GetFormattingConventions(&conventions); + bool use24HourClock = conventions.Use24HourClock(); + desk_settings* settings = ((TBarApp*)be_app)->Settings(); + // Create the time view fTime = new TTimeView(fMinimumTrayWidth, kMaxReplicantHeight - 1.0, - ((TBarApp*)be_app)->Settings()->timeFormat); + use24HourClock, settings->showSeconds, settings->showDayOfWeek, + settings->showTimeZone); } @@ -202,47 +208,6 @@ TReplicantTray::DetachedFromWindow() } -void -TReplicantTray::SaveTimeSettings() -{ - if (fTime == NULL) - return; - - desk_settings* settings = ((TBarApp*)be_app)->Settings(); - settings->showTime = !fTime->IsHidden(); - settings->timeFormat = fTime->TimeFormat(); -} - - -void -TReplicantTray::ShowHideTime() -{ - if (fTime == NULL) - return; - - if (fTime->IsHidden()) - fTime->Show(); - else - fTime->Hide(); - - RealignReplicants(); - AdjustPlacement(); -} - - -void -TReplicantTray::UpdateTimeFormat(uint32 timeFormat) -{ - if (fTime == NULL) - return; - - fTime->SetTimeFormat(timeFormat); - - RealignReplicants(); - AdjustPlacement(); -} - - /*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth if not in multirowmode and greater than kMinimumReplicantCount the width should be calculated based on the actual replicant widths @@ -329,7 +294,7 @@ TReplicantTray::MessageReceived(BMessage* message) conventions.SetExplicitUse24HourClock(use24HourClock); BPrivate::MutableLocaleRoster::Default()-> SetDefaultFormattingConventions(conventions); - fTime->Update(); + fTime->SetUse24HourClock(use24HourClock); // time string reformat -> realign RealignReplicants(); AdjustPlacement(); @@ -338,17 +303,38 @@ TReplicantTray::MessageReceived(BMessage* message) break; } - case kTimeFormatChanged: - { + case kShowSeconds: if (fTime == NULL) return; - uint32 timeFormat; - if (message->FindUInt32("time format", &timeFormat) == B_OK) - UpdateTimeFormat(timeFormat); + fTime->SetShowSeconds(!fTime->ShowSeconds()); + // time string reformat -> realign + RealignReplicants(); + AdjustPlacement(); + break; + + case kShowDayOfWeek: + if (fTime == NULL) + return; + + fTime->SetShowDayOfWeek(!fTime->ShowDayOfWeek()); + + // time string reformat -> realign + RealignReplicants(); + AdjustPlacement(); + break; + + case kShowTimeZone: + if (fTime == NULL) + return; + + fTime->SetShowTimeZone(!fTime->ShowTimeZone()); + + // time string reformat -> realign + RealignReplicants(); + AdjustPlacement(); break; - } #ifdef DB_ADDONS case B_NODE_MONITOR: @@ -363,28 +349,6 @@ TReplicantTray::MessageReceived(BMessage* message) } -void -TReplicantTray::ShowReplicantMenu(BPoint point) -{ - BPopUpMenu* menu = new BPopUpMenu("", false, false); - menu->SetFont(be_plain_font); - - // If clock is visible show the extended menu, otherwise show "Show Time" - - if (!fTime->IsHidden()) - fTime->ShowTimeOptions(ConvertToScreen(point)); - else { - BMenuItem* item = new BMenuItem(B_TRANSLATE("Show Time"), - new BMessage(kShowHideTime)); - menu->AddItem(item); - menu->SetTargetForItems(this); - BPoint where = ConvertToScreen(point); - menu->Go(where, true, true, BRect(where - BPoint(4, 4), - where + BPoint(4, 4)), true); - } -} - - void TReplicantTray::MouseDown(BPoint where) { @@ -423,8 +387,55 @@ TReplicantTray::MouseDown(BPoint where) BView::MouseDown(where); } + +void +TReplicantTray::ShowReplicantMenu(BPoint point) +{ + BPopUpMenu* menu = new BPopUpMenu("", false, false); + menu->SetFont(be_plain_font); + + // If clock is visible show the extended menu, otherwise show "Show time" + + if (!fTime->IsHidden()) + fTime->ShowTimeOptions(ConvertToScreen(point)); + else { + BMenuItem* item = new BMenuItem(B_TRANSLATE("Show time"), + new BMessage(kShowHideTime)); + menu->AddItem(item); + menu->SetTargetForItems(this); + BPoint where = ConvertToScreen(point); + menu->Go(where, true, true, BRect(where - BPoint(4, 4), + where + BPoint(4, 4)), true); + } +} + + +void +TReplicantTray::SetMultiRow(bool state) +{ + fMultiRowMode = state; +} + + +void +TReplicantTray::ShowHideTime() +{ + if (fTime == NULL) + return; + + if (fTime->IsHidden()) + fTime->Show(); + else + fTime->Hide(); + + RealignReplicants(); + AdjustPlacement(); +} + + #ifdef DB_ADDONS + void TReplicantTray::InitAddOnSupport() { @@ -1219,13 +1230,6 @@ TReplicantTray::RealignReplicants(int32 startIndex) } -void -TReplicantTray::SetMultiRow(bool state) -{ - fMultiRowMode = state; -} - - status_t TReplicantTray::_SaveSettings() { @@ -1239,11 +1243,25 @@ TReplicantTray::_SaveSettings() if ((result = file.InitCheck()) == B_OK) result = fAddOnSettings.Flatten(&file); } - + return result; } +void +TReplicantTray::SaveTimeSettings() +{ + if (fTime == NULL) + return; + + desk_settings* settings = ((TBarApp*)be_app)->Settings(); + settings->showTime = !fTime->IsHidden(); + settings->showSeconds = fTime->ShowSeconds(); + settings->showDayOfWeek = fTime->ShowDayOfWeek(); + settings->showTimeZone = fTime->ShowTimeZone(); +} + + // #pragma mark - diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h index 22577f9975..2fd756d47e 100644 --- a/src/apps/deskbar/StatusView.h +++ b/src/apps/deskbar/StatusView.h @@ -76,85 +76,98 @@ class TReplicantShelf; class TReplicantTray : public BView { public: - TReplicantTray(TBarView* bv, bool vertical); - virtual ~TReplicantTray(); + TReplicantTray(TBarView* barView, + bool vertical); + virtual ~TReplicantTray(); - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); - virtual void MouseDown(BPoint point); - virtual void MessageReceived(BMessage*); - virtual void GetPreferredSize(float*, float*); + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + virtual void MouseDown(BPoint point); + virtual void MessageReceived(BMessage*); + virtual void GetPreferredSize(float*, float*); - void AdjustPlacement(); + void AdjustPlacement(); + void ShowReplicantMenu(BPoint); - void ShowReplicantMenu(BPoint); + void SetMultiRow(bool state); + bool IsMultiRow() const + { return fMultiRowMode; } - void SetMultiRow(bool state); - bool IsMultiRow() const { return fMultiRowMode; } + TTimeView* Time() const { return fTime; } + void ShowHideTime(); - status_t ItemInfo(int32 target, const char** name); - status_t ItemInfo(const char* name, int32* id); - status_t ItemInfo(int32 index, const char** name, int32* id); + status_t ItemInfo(int32 target, const char** name); + status_t ItemInfo(const char* name, int32* id); + status_t ItemInfo(int32 index, const char** name, + int32* id); - bool IconExists(int32 target, bool byIndex = false); - bool IconExists(const char* name); + bool IconExists(int32 target, bool byIndex = false); + bool IconExists(const char* name); - int32 IconCount() const; + int32 IconCount() const; - status_t AddIcon(BMessage*, int32* id, const entry_ref* = NULL); + status_t AddIcon(BMessage*, int32* id, + const entry_ref* = NULL); - void RemoveIcon(int32 target, bool byIndex = false); - void RemoveIcon(const char* name); + void RemoveIcon(int32 target, + bool byIndex = false); + void RemoveIcon(const char* name); - BRect IconFrame(int32 target, bool byIndex = false); - BRect IconFrame(const char* name); + BRect IconFrame(int32 target, + bool byIndex = false); + BRect IconFrame(const char* name); - bool AcceptAddon(BRect frame, BMessage* message); - void RealignReplicants(int32 startIndex = -1); + bool AcceptAddon(BRect frame, + BMessage* message); + void RealignReplicants(int32 startIndex = -1); - void SaveTimeSettings(); + void SaveTimeSettings(); #ifdef DB_ADDONS - status_t LoadAddOn(BEntry* entry, int32* id, bool addToSettings = true); + status_t LoadAddOn(BEntry* entry, int32* id, + bool addToSettings = true); #endif private: - BView* ViewAt(int32* index, int32* id, int32 target, bool byIndex = false); - BView* ViewAt(int32* index, int32* id, const char* name); + BView* ViewAt(int32* index, int32* id, + int32 target, + bool byIndex = false); + BView* ViewAt(int32* index, int32* id, + const char* name); - void RealReplicantAdjustment(int32 startindex); + void RealReplicantAdjustment(int32 startindex); #ifdef DB_ADDONS - void InitAddOnSupport(); - void DeleteAddOnSupport(); + void InitAddOnSupport(); + void DeleteAddOnSupport(); - DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef); - DeskbarItemInfo* DeskbarItemFor(int32 id); - bool NodeExists(node_ref &nodeRef); + DeskbarItemInfo* DeskbarItemFor(node_ref &nodeRef); + DeskbarItemInfo* DeskbarItemFor(int32 id); + bool NodeExists(node_ref &nodeRef); - void HandleEntryUpdate(BMessage*); - status_t AddItem(int32 id, node_ref nodeRef, BEntry &entry, bool isAddon); + void HandleEntryUpdate(BMessage*); + status_t AddItem(int32 id, node_ref nodeRef, + BEntry &entry, bool isAddon); - void UnloadAddOn(node_ref*, dev_t*, bool which, bool removeAll); - void RemoveItem(int32 id); + void UnloadAddOn(node_ref*, dev_t*, bool which, + bool removeAll); + void RemoveItem(int32 id); - void MoveItem(entry_ref*, ino_t toDirectory); + void MoveItem(entry_ref*, ino_t toDirectory); #endif - BPoint LocationForReplicant(int32 index, float width); - BShelf* Shelf() const; + BPoint LocationForReplicant(int32 index, + float width); + BShelf* Shelf() const; - void ShowHideTime(); - void UpdateTimeFormat(uint32 timeFormat); - - status_t _SaveSettings(); + status_t _SaveSettings(); friend class TReplicantShelf; - TTimeView* fTime; - TBarView* fBarView; - TReplicantShelf* fShelf; - BRect fRightBottomReplicant; + TTimeView* fTime; + TBarView* fBarView; + TReplicantShelf* fShelf; + BRect fRightBottomReplicant; int32 fLastReplicant; bool fMultiRowMode; diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 230187d5bf..6417afc5aa 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -66,16 +66,20 @@ enum { #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "TimeView" -TTimeView::TTimeView(float maxWidth, float height, uint32 timeFormat) +TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock, + bool showSeconds, bool showDayOfWeek, bool showTimeZone) : BView(BRect(-100, -100, -90, -90), "_deskbar_tv_", - B_FOLLOW_RIGHT | B_FOLLOW_TOP, - B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS), + B_FOLLOW_RIGHT | B_FOLLOW_TOP, + B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS), fParent(NULL), fMaxWidth(maxWidth), fHeight(height), fOrientation(true), - fTimeFormat(timeFormat) + fUse24HourClock(use24HourClock), + fShowSeconds(showSeconds), + fShowDayOfWeek(showDayOfWeek), + fShowTimeZone(showTimeZone) { fCurrentTime = fLastTime = time(NULL); fSeconds = fMinute = fHour = 0; @@ -84,6 +88,7 @@ TTimeView::TTimeView(float maxWidth, float height, uint32 timeFormat) fLastTimeStr[0] = 0; fLastDateStr[0] = 0; fNeedToUpdate = true; + UpdateTimeFormat(); fLocale = *BLocale::Default(); } @@ -141,8 +146,8 @@ TTimeView::AttachedToWindow() } else SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - ResizeToPreferred(); CalculateTextPlacement(); + ResizeToPreferred(); } @@ -307,10 +312,62 @@ TTimeView::SetOrientation(bool orientation) } -void -TTimeView::SetTimeFormat(uint32 timeFormat) +bool +TTimeView::Use24HourClock() const { - fTimeFormat = timeFormat; + return fUse24HourClock; +} + + +void +TTimeView::SetUse24HourClock(bool use24HourClock) +{ + fUse24HourClock = use24HourClock; + Update(); +} + + +bool +TTimeView::ShowSeconds() const +{ + return fShowSeconds; +} + + +void +TTimeView::SetShowSeconds(bool show) +{ + fShowSeconds = show; + Update(); +} + + +bool +TTimeView::ShowDayOfWeek() const +{ + return fShowDayOfWeek; +} + + +void +TTimeView::SetShowDayOfWeek(bool show) +{ + fShowDayOfWeek = show; + Update(); +} + + +bool +TTimeView::ShowTimeZone() const +{ + return fShowTimeZone; +} + + +void +TTimeView::SetShowTimeZone(bool show) +{ + fShowTimeZone = show; Update(); } @@ -347,20 +404,7 @@ TTimeView::ShowCalendar(BPoint where) void TTimeView::GetCurrentTime() { - switch (fTimeFormat) { - case B_LONG_TIME_FORMAT: - fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime, - B_LONG_TIME_FORMAT); - break; - case B_MEDIUM_TIME_FORMAT: - fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime, - B_MEDIUM_TIME_FORMAT); - break; - default: - fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime, - B_SHORT_TIME_FORMAT); - } - + fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime, fTimeFormat); } @@ -391,6 +435,15 @@ TTimeView::CalculateTextPlacement() BFont font; GetFont(&font); + + // If 12 hour clock with all options turned on shrink font size to fit. + if (!fUse24HourClock && fShowSeconds && fShowDayOfWeek && fShowTimeZone) + font.SetSize(11.0); + else + font.SetSize(12.0); + + SetFont(&font, B_FONT_SIZE); + const char* stringArray[1]; stringArray[0] = fCurrentTimeStr; BRect rectArray[1]; @@ -410,7 +463,7 @@ TTimeView::ShowTimeOptions(BPoint point) menu->SetFont(be_plain_font); BMenuItem* item; - item = new BMenuItem(B_TRANSLATE("Open time preferences" B_UTF8_ELLIPSIS), + item = new BMenuItem(B_TRANSLATE("Time preferences" B_UTF8_ELLIPSIS), new BMessage(kChangeTime)); menu->AddItem(item); @@ -438,9 +491,37 @@ TTimeView::Update() GetCurrentDate(); SetToolTip(fCurrentDateStr); - ResizeToPreferred(); + UpdateTimeFormat(); + CalculateTextPlacement(); + ResizeToPreferred(); if (fParent) fParent->Invalidate(); } + + +void +TTimeView::UpdateTimeFormat() +{ + BString timeFormat; + + if (fShowDayOfWeek) + timeFormat.Append("eee "); + + if (fUse24HourClock) + timeFormat.Append("H:mm"); + else + timeFormat.Append("h:mm"); + + if (fShowSeconds) + timeFormat.Append(":ss"); + + if (!fUse24HourClock) + timeFormat.Append(" a"); + + if (fShowTimeZone) + timeFormat.Append(" V"); + + fTimeFormat = timeFormat; +} diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index 47a94b13cf..fcb26f1723 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -41,10 +41,8 @@ All rights reserved. #include #include +#include "PreferencesWindow.h" // For message constants -const uint32 kShowHideTime = 'shtm'; -const uint32 kTimeIntervalChanged = 'tivc'; -const uint32 kTimeFormatChanged = 'tfmc'; class BCountry; class BMessageRunner; @@ -53,69 +51,88 @@ class BMessageRunner; class _EXPORT TTimeView; #endif - class TTimeView : public BView { - public: - TTimeView(float maxWidth, float height, uint32 timeFormat); - TTimeView(BMessage* data); - ~TTimeView(); +public: + TTimeView(float maxWidth, float height, + bool use24HourClock, bool showSeconds, + bool showDayOfWeek, bool showTimeZone); + TTimeView(BMessage* data); + ~TTimeView(); #ifdef AS_REPLICANT - status_t Archive(BMessage* data, bool deep = true) const; - static BArchivable* Instantiate(BMessage* data); + status_t Archive(BMessage* data, + bool deep = true) const; + static BArchivable* Instantiate(BMessage* data); #endif - void AttachedToWindow(); - void Draw(BRect update); - void FrameMoved(BPoint); - void GetPreferredSize(float* width, float* height); - void MessageReceived(BMessage*); - void MouseDown(BPoint where); - void Pulse(); - void ResizeToPreferred(); + void AttachedToWindow(); + void Draw(BRect update); + void FrameMoved(BPoint); + void GetPreferredSize(float* width, float* height); + void MessageReceived(BMessage*); + void MouseDown(BPoint where); + void Pulse(); + void ResizeToPreferred(); - bool Orientation() const; - void SetOrientation(bool o); + bool Orientation() const; + void SetOrientation(bool o); - uint32 TimeFormat() const; - void SetTimeFormat(uint32 timeFormat); + bool Use24HourClock() const; + void SetUse24HourClock(bool use24HourClock); - void ShowCalendar(BPoint where); + bool ShowSeconds() const; + void SetShowSeconds(bool show); - private: + bool ShowDayOfWeek() const; + void SetShowDayOfWeek(bool show); + + bool ShowTimeZone() const; + void SetShowTimeZone(bool show); + + void ShowCalendar(BPoint where); + +private: friend class TReplicantTray; - void GetCurrentTime(); - void GetCurrentDate(); - void CalculateTextPlacement(); - void ShowTimeOptions(BPoint); - void Update(); + void GetCurrentTime(); + void GetCurrentDate(); + void CalculateTextPlacement(); + void ShowTimeOptions(BPoint); + void Update(); + void UpdateTimeFormat(); - BView *fParent; - bool fNeedToUpdate; + BView* fParent; + bool fNeedToUpdate; - time_t fCurrentTime; - time_t fLastTime; + time_t fCurrentTime; + time_t fLastTime; - char fCurrentTimeStr[64]; - char fLastTimeStr[64]; - char fCurrentDateStr[64]; - char fLastDateStr[64]; + char fCurrentTimeStr[64]; + char fLastTimeStr[64]; + char fCurrentDateStr[64]; + char fLastDateStr[64]; - int fSeconds; - int fMinute; - int fHour; + int fSeconds; + int fMinute; + int fHour; - float fMaxWidth; - float fHeight; - bool fOrientation; // vertical = true - uint32 fTimeFormat; - BPoint fTimeLocation; - BPoint fDateLocation; + float fMaxWidth; + float fHeight; + bool fOrientation; // vertical = true - BMessenger fCalendarWindow; + bool fUse24HourClock; + bool fShowSeconds; + bool fShowDayOfWeek; + bool fShowTimeZone; + BString fTimeFormat; - BLocale fLocale; // For date and time localizing purposes + BPoint fTimeLocation; + BPoint fDateLocation; + + BMessenger fCalendarWindow; + + // For date and time localization purposes + BLocale fLocale; }; @@ -126,12 +143,4 @@ TTimeView::Orientation() const } -inline uint32 -TTimeView::TimeFormat() const -{ - return fTimeFormat; -} - - #endif /* TIME_VIEW_H */ - diff --git a/src/kits/locale/Locale.cpp b/src/kits/locale/Locale.cpp index 4a23de6eb3..b25a41699b 100644 --- a/src/kits/locale/Locale.cpp +++ b/src/kits/locale/Locale.cpp @@ -1,8 +1,9 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. -** Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de. -** All rights reserved. Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2010-2011, Oliver Tappe, zooey@hirschkaefer.de. + * Copyright 2012, John Scipione, jscipione@gmail.com + * All rights reserved. Distributed under the terms of the OpenBeOS License. + */ #include @@ -509,6 +510,34 @@ BLocale::FormatTime(char* string, size_t maxSize, time_t time, } +ssize_t +BLocale::FormatTime(char* string, size_t maxSize, time_t time, + BString format) const +{ + BAutolock lock(fLock); + if (!lock.IsLocked()) + return B_ERROR; + + if (format == NULL || format.CountChars() <= 0) + return B_BAD_VALUE; + + ObjectDeleter timeFormatter(_CreateTimeFormatter(format)); + if (timeFormatter.Get() == NULL) + return B_NO_MEMORY; + + UnicodeString icuString; + timeFormatter->format((UDate)time * 1000, icuString); + + CheckedArrayByteSink stringConverter(string, maxSize); + icuString.toUTF8(stringConverter); + + if (stringConverter.Overflowed()) + return B_BAD_VALUE; + + return stringConverter.NumberOfBytesWritten(); +} + + status_t BLocale::FormatTime(BString* string, time_t time, BTimeFormatStyle style, const BTimeZone* timeZone) const @@ -542,6 +571,40 @@ BLocale::FormatTime(BString* string, time_t time, BTimeFormatStyle style, } +status_t +BLocale::FormatTime(BString* string, time_t time, BString format, + const BTimeZone* timeZone) const +{ + BAutolock lock(fLock); + if (!lock.IsLocked()) + return B_ERROR; + + if (format == NULL || format.CountChars() <= 0) + return B_BAD_VALUE; + + ObjectDeleter timeFormatter(_CreateTimeFormatter(format)); + if (timeFormatter.Get() == NULL) + return B_NO_MEMORY; + + if (timeZone != NULL) { + ObjectDeleter icuTimeZone( + TimeZone::createTimeZone(timeZone->ID().String())); + if (icuTimeZone.Get() == NULL) + return B_NO_MEMORY; + timeFormatter->setTimeZone(*icuTimeZone.Get()); + } + + UnicodeString icuString; + timeFormatter->format((UDate)time * 1000, icuString); + + string->Truncate(0); + BStringByteSink stringConverter(string); + icuString.toUTF8(stringConverter); + + return B_OK; +} + + status_t BLocale::FormatTime(BString* string, int*& fieldPositions, int& fieldCount, time_t time, BTimeFormatStyle style) const @@ -607,7 +670,7 @@ BLocale::GetTimeFields(BDateElement*& fields, int& fieldCount, icu::FieldPositionIterator positionIterator; UnicodeString icuString; time_t now; - timeFormatter->format((UDate)time(&now) * 1000, icuString, + timeFormatter->format((UDate)time(&now) * 1000, icuString, &positionIterator, error); if (error != U_ZERO_ERROR)