tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / preferences / time / TimeZoneListView.cpp
blobc0111eb5ecc4d23f8d62449eb4a1ec668679cf4f
1 /*
2 * Copyright 2012, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Sean Bailey <ziusudra@gmail.com>
7 */
10 #include "TimeZoneListView.h"
12 #include <new>
14 #include <Catalog.h>
15 #include <DateFormat.h>
16 #include <Locale.h>
17 #include <String.h>
18 #include <TimeZone.h>
19 #include <ToolTip.h>
21 #include "TimeZoneListItem.h"
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "Time"
28 TimeZoneListView::TimeZoneListView(void)
30 BOutlineListView("cityList", B_SINGLE_SELECTION_LIST)
35 TimeZoneListView::~TimeZoneListView()
40 bool
41 TimeZoneListView::GetToolTipAt(BPoint point, BToolTip** _tip)
43 TimeZoneListItem* item = static_cast<TimeZoneListItem*>(
44 this->ItemAt(this->IndexOf(point)));
45 if (item == NULL || !item->HasTimeZone())
46 return false;
48 BString nowInTimeZone;
49 time_t now = time(NULL);
50 fTimeFormat.Format(nowInTimeZone, now, B_SHORT_TIME_FORMAT,
51 &item->TimeZone());
53 BString dateInTimeZone;
54 fDateFormat.Format(dateInTimeZone, now, B_SHORT_DATE_FORMAT,
55 &item->TimeZone());
57 BString toolTip = item->Text();
58 toolTip << '\n' << item->TimeZone().ShortName() << " / "
59 << item->TimeZone().ShortDaylightSavingName()
60 << B_TRANSLATE("\nNow: ") << nowInTimeZone
61 << " (" << dateInTimeZone << ')';
63 SetToolTip(toolTip.String());
65 *_tip = ToolTip();
67 return true;