[gnome-panel] clock: Correctly deal with leap seconds for updates



commit 11346ea2992a069e523bc50285b7431358e48c6a
Author: Andrey Vihrov <andrey vihrov gmail com>
Date:   Tue May 24 01:06:14 2011 +0200

    clock: Correctly deal with leap seconds for updates
    
    We need to use localtime() to take into account leap seconds that might
    exist, when defining the new timeout to update the clock. Else, the
    clock will not update when a minute change, but a bit later.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=604317

 applets/clock/clock.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 2de888a..95a929a 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -310,14 +310,20 @@ clock_set_timeout (ClockData *cd,
 		}
 	} else {
  		struct timeval tv;
+		struct tm *tm;
 
 		gettimeofday (&tv, NULL);
  		timeouttime = (G_USEC_PER_SEC - tv.tv_usec)/1000+1;
 
 		/* timeout of one minute if we don't care about the seconds */
  		if (cd->format != CLOCK_FORMAT_UNIX &&
-		    !cd->showseconds)
- 			timeouttime += 1000 * (59 - now % 60);
+		    !cd->showseconds) {
+			/* we use localtime() to handle leap seconds, see
+			 * https://bugzilla.gnome.org/show_bug.cgi?id=604317 */
+			tm = localtime (&now);
+			if (tm->tm_sec < 60)
+				timeouttime += 1000 * (59 - tm->tm_sec);
+		}
  	}
 
 	cd->timeout = g_timeout_add (timeouttime,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]