hrev44850 adds 1 changeset to branch 'master' old head: f3d8f2a599733e498e8d099860a92f5b5c695a52 new head: debbd7bd8a94b4a35d35e395f09d1eda39da6605 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=debbd7b+^f3d8f2a ---------------------------------------------------------------------------- debbd7b: Update Deskbar Clock to use predefined time formats ... with day of week tacked on at the beginning. This fixes #9143 by better allowing the Locale Kit to format the time. It was localized before but now also uses localized time separators. There might be still a bug with day of week though, depending on if day of week should go before or after the time in your locale (It is hard coded to before). [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev44850 Commit: debbd7bd8a94b4a35d35e395f09d1eda39da6605 URL: http://cgit.haiku-os.org/haiku/commit/?id=debbd7b Author: John Scipione <jscipione@xxxxxxxxx> Date: Fri Nov 16 23:51:17 2012 UTC Ticket: https://dev.haiku-os.org/ticket/9143 ---------------------------------------------------------------------------- 2 files changed, 20 insertions(+), 28 deletions(-) src/apps/deskbar/TimeView.cpp | 47 +++++++++++++++++---------------------- src/apps/deskbar/TimeView.h | 1 - ---------------------------------------------------------------------------- diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp index 014cb9a..519c0ea 100644 --- a/src/apps/deskbar/TimeView.cpp +++ b/src/apps/deskbar/TimeView.cpp @@ -88,7 +88,6 @@ TTimeView::TTimeView(float maxWidth, float height, bool use24HourClock, fLastTimeStr[0] = 0; fLastDateStr[0] = 0; fNeedToUpdate = true; - UpdateTimeFormat(); fLocale = *BLocale::Default(); } @@ -385,7 +384,24 @@ TTimeView::ShowCalendar(BPoint where) void TTimeView::GetCurrentTime() { - fLocale.FormatTime(fCurrentTimeStr, 64, fCurrentTime, fTimeFormat); + char tmp[sizeof(fCurrentTimeStr)]; + ssize_t offset = 0; + + if (fShowSeconds) { + fLocale.FormatTime(tmp, sizeof(fCurrentTimeStr), fCurrentTime, + B_MEDIUM_TIME_FORMAT); + } else { + fLocale.FormatTime(tmp, sizeof(fCurrentTimeStr), fCurrentTime, + B_SHORT_TIME_FORMAT); + } + + if (fShowDayOfWeek) { + BString timeFormat("eee "); + offset = fLocale.FormatTime(fCurrentTimeStr, sizeof(fCurrentTimeStr), + fCurrentTime, timeFormat); + } + + strlcpy(fCurrentTimeStr + offset, tmp, sizeof(fCurrentTimeStr) - offset); } @@ -394,7 +410,8 @@ TTimeView::GetCurrentDate() { char tmp[64]; - fLocale.FormatDate(tmp, 64, fCurrentTime, B_FULL_DATE_FORMAT); + fLocale.FormatDate(tmp, sizeof(fCurrentDateStr), fCurrentTime, + B_FULL_DATE_FORMAT); // remove leading 0 from date when month is less than 10 (MM/DD/YY) // or remove leading 0 from date when day is less than 10 (DD/MM/YY) @@ -460,7 +477,6 @@ void TTimeView::Update() { fLocale = *BLocale::Default(); - UpdateTimeFormat(); GetCurrentTime(); GetCurrentDate(); @@ -472,26 +488,3 @@ TTimeView::Update() if (fParent != NULL) 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"); - - fTimeFormat = timeFormat; -} diff --git a/src/apps/deskbar/TimeView.h b/src/apps/deskbar/TimeView.h index 24c5495..f273a10 100644 --- a/src/apps/deskbar/TimeView.h +++ b/src/apps/deskbar/TimeView.h @@ -96,7 +96,6 @@ private: void CalculateTextPlacement(); void ShowTimeOptions(BPoint); void Update(); - void UpdateTimeFormat(); BView* fParent; bool fNeedToUpdate;