diff options
Diffstat (limited to 'src/client/infowidget.cc')
-rw-r--r-- | src/client/infowidget.cc | 30 |
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; } |