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
parent3de78ec1bef2a0274a719ea229709523650ade40 (diff)
Refactored the sys::localtime routines.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cc4
-rw-r--r--src/client/infowidget.cc30
2 files changed, 18 insertions, 16 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index 5b72146..d761e6e 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -196,13 +196,13 @@ void Client::run()
}
if (cl_framerate->value()) {
- client_frame_lenght = (Uint32) roundf(1000.0f / cl_framerate->value());
+ client_frame_lenght = (Uint32) floorf(1000.0f / cl_framerate->value());
} else {
client_frame_lenght = 0;
}
// only advance per microsecond frame
- Uint32 d = client_current_timestamp - client_previous_timestamp;
+ const Uint32 d = client_current_timestamp - client_previous_timestamp;
if ((d > 0)) {
if (d >= client_frame_lenght) {
frame(client_current_timestamp);
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;
}