aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/FbTime.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-01-26 08:21:47 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-01-26 08:21:47 (GMT)
commit716532dd47d718cb548da5f65b53a8b744ce235f (patch)
tree683de0875820ce361e2c02efc69d3ad103f3f90a /src/FbTk/FbTime.hh
parente7bfc639323bf5d4b207323b6e2fd275dcb5d825 (diff)
downloadfluxbox-716532dd47d718cb548da5f65b53a8b744ce235f.zip
fluxbox-716532dd47d718cb548da5f65b53a8b744ce235f.tar.bz2
Calculates timeouts of ClockTool based upon System Clock
Users expect time switches to happen upon system clock times. Calculating the timeout for the next refresh of the shown time via the monotonic clock is wrong: The monotonic clock yields values based upon some arbitrary point in time which might be off a little bit to the system clock, a 'full' minute of the monotonic clock might be in the midst of a system clock minute.
Diffstat (limited to 'src/FbTk/FbTime.hh')
-rw-r--r--src/FbTk/FbTime.hh15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/FbTk/FbTime.hh b/src/FbTk/FbTime.hh
index 2b33dd8..3d80b12 100644
--- a/src/FbTk/FbTime.hh
+++ b/src/FbTk/FbTime.hh
@@ -34,7 +34,7 @@
34 34
35namespace FbTk { 35namespace FbTk {
36 36
37// time in micro-seconds, monotonic increasing 37// time in micro-seconds
38// 38//
39// interesting links: 39// interesting links:
40// 40//
@@ -44,12 +44,17 @@ namespace FbTk {
44namespace FbTime { 44namespace FbTime {
45 45
46 const uint64_t IN_MILLISECONDS = 1000L; 46 const uint64_t IN_MILLISECONDS = 1000L;
47 const uint64_t IN_SECONDS = 1000L * 1000L; 47 const uint64_t IN_SECONDS = 1000L * IN_MILLISECONDS;
48 const uint64_t IN_MINUTES = 60 * IN_SECONDS;
48 49
49 uint64_t now(); 50 uint64_t mono(); // point in time, always monotonic
51 uint64_t system(); // system time, might jump (DST, leap seconds)
50 52
51 // calculates the remaining microseconds up to the next full 'unit' 53 // calculates the remaining microseconds from 'now' up to the
52 uint64_t remainingNext(uint64_t unit); 54 // next full 'unit'
55 inline uint64_t remainingNext(uint64_t now, uint64_t unit) {
56 return (unit - (now % unit) - 1);
57 }
53 58
54} // namespace FbTime 59} // namespace FbTime
55 60