Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-05-09 20:22:34 +0000
committerStijn Buys <ingar@osirion.org>2011-05-09 20:22:34 +0000
commitbb0f860989f84b901f80017ae0139a3fc0446dc1 (patch)
tree3b9ef3a5164326d2ad4b531904603ea2afdb40e3 /src/client/infowidget.cc
parent3de78ec1bef2a0274a719ea229709523650ade40 (diff)
Refactored the sys::localtime routines.
Diffstat (limited to 'src/client/infowidget.cc')
-rw-r--r--src/client/infowidget.cc30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/client/infowidget.cc b/src/client/infowidget.cc
index ed118a8..52af5ef 100644
--- a/src/client/infowidget.cc
+++ b/src/client/infowidget.cc
@@ -199,22 +199,24 @@ void ClockInfoWidget::draw()
{
if (mode() == ClockOff)
return;
+
+ int hours, minutes, seconds;
+ sys::get_localtime(hours, minutes, seconds);
- std::ostringstream clockstr;
- const unsigned long current_time = sys::time();
- unsigned long hours = current_time / 3600;
- unsigned long minutes = (current_time % 3600) / 60;
- //unsigned long seconds = current_time % 60;
-
+ std::ostringstream clockstr;
clockstr << std::setfill('0') << std::setw(2);
- if (mode() == Clock12Hours) {
- if (hours > 12) {
- clockstr << hours-12 << ":" << std::setfill('0') << std::setw(2) << minutes << "pm";
- } else {
- if (hours == 0)
- hours +=12;
- clockstr << hours << ":" << std::setfill('0') << std::setw(2) << minutes << "am";
- }
+
+ if (mode() == Clock12Hours) {
+ std::string suffix("am");
+
+ if (hours >= 12) {
+ suffix[1] = 'p';
+ hours -= 12;
+ }
+ if (hours == 0) {
+ hours += 12;
+ }
+ clockstr << hours << ":" << std::setfill('0') << std::setw(2) << minutes << suffix;
} else {
clockstr << " " << hours << ":" << std::setfill('0') << std::setw(2) << minutes;
}