Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tty-clock is late #40

Closed
anarcat opened this issue Jan 13, 2017 · 2 comments
Closed

tty-clock is late #40

anarcat opened this issue Jan 13, 2017 · 2 comments

Comments

@anarcat
Copy link
Collaborator

anarcat commented Jan 13, 2017

When compared with other software, tty-clock seems actually to run one or two seconds late.

snap-2017 01 13-10 27 23

In the above screenshot, 4 clocks are running, from top to bottom:

  1. xmobar (the status bar of xmonad)
  2. xclock -d -update 1
  3. vtclock -v -3 (nothing special about those flags, just a nicer font)
  4. tty-clock -s

Note that we don't see it in the screenshot, but xmobar is actually lagging a little behind the other two clocks, say about 500ms. Here's a screencast that shows the behavior more precisely.

I find it mind-boggling that 4 clocks can't agree on the time on my computer, this gotta have some profound meaning involving long hair and swiss patent offices, but i am not certain... ;)

@anarcat
Copy link
Collaborator Author

anarcat commented Jan 13, 2017

for the record:

  1. xmobar and taffybar just refresh the display whenever it feels like it and checks the actual time to display it
  2. xclock does some funky arithmetic to figure when to wakeup
  3. vtclock does a busyloop on gettimeofday
  4. ttyclock just sleeps the configured time then calls the localtime on the previous time set, then sets the time (!!)
     ttyclock->tm = localtime(&(ttyclock->lt));
     if(ttyclock->option.utc) {
         ttyclock->tm = gmtime(&(ttyclock->lt));
     }
     ttyclock->lt = time(NULL);

i'll send a pr to fix this. :) with the patch, the display is more consistent with xclock and friends.

anarcat added a commit to anarcat/tty-clock that referenced this issue Jan 13, 2017
the way this was working before, we would populate the ttyclock->lt
field *after* fetching the ttyclock->tm structure, which means that
would get the `localtime` of the *previous* iteration. this created a
one second delay in the clock display that was, I believe,
unintentional. this accounts for part of the 2s delay when compared to
other clocks like vtclock or xclock.

Closes: xorg62#40
@anarcat
Copy link
Collaborator Author

anarcat commented Jan 13, 2017

should be fixed in #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant