aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ClockTool.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 0812092..514d45d 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -247,9 +247,20 @@ unsigned int ClockTool::height() const {
247 247
248void ClockTool::updateTime() { 248void ClockTool::updateTime() {
249 249
250 time_t t = time(NULL); 250 // time() might result in a different seconds-since-epoch than
251 // gettimeofday() due to the fact that time() might be implemented by just
252 // returning the amount of elapsed full seconds without taking into
253 // account the sum of accumulated sub-seconds might be bigger than a
254 // second. in this situation time() is 1s behind gettimeofday() which would
255 // result in having the same 'text' and thus fluxbox would skip this
256 // round. reference:
257 //
258 // http://stackoverflow.com/questions/22917318/time-and-gettimeofday-return-different-seconds/23597725#23597725
251 259
252 if (t != -1) { 260 uint64_t now = FbTk::FbTime::system();
261 time_t t = static_cast<time_t>(now / 1000000L);
262
263 if (t != static_cast<time_t>(-1)) {
253 264
254 char buf[255]; 265 char buf[255];
255 int len; 266 int len;