public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* PATCH Make hwclock leap-second-aware
@ 2013-03-18  4:48 Joseph Parmelee
  2013-03-18  9:48 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph Parmelee @ 2013-03-18  4:48 UTC (permalink / raw)
  To: util-linux

[-- Attachment #1: Type: TEXT/PLAIN, Size: 831 bytes --]

Hello:

Attached is a patch file leap_seconds.patch against util-linux-2.22.2
that allows leap seconds to be included in hwclock --show or --hctosys. 
The current code uses the default UTC zonefile in reading the hardware
RTC with mktime().  This zonefile usually does not include leap
seconds.  As of this date there have been a total of 25 leap seconds
added since the epoch (start of 1970).  This is particularly a problem
for systems using ntp to maintain their system clocks because ntp does
take leap seconds into account.  A user can specify a leap-second-aware
zonefile via /etc/localtime.  By defining the environment variable
TZUTC, mktime() can be induced to use a matching UTC zonefile that
includes leap seconds.  The default behavior (TZUTC undefined) is
unchanged.

Regards,

Joseph Parmelee
jparmele at wildbear.com

[-- Attachment #2: Leap seconds patch for hwclock --]
[-- Type: TEXT/PLAIN, Size: 843 bytes --]

--- sys-utils/hwclock.c.orig	2012-12-12 14:04:22.976355744 -0600
+++ sys-utils/hwclock.c	2013-03-16 18:57:48.774606768 -0600
@@ -382,8 +382,15 @@
 	 */
 	zone = getenv("TZ");	/* remember original time zone */
 	if (universal) {
-		/* Set timezone to UTC */
-		setenv("TZ", "", TRUE);
+		/* Set timezone to UTC as defined by the environment
+		 * variable TZUTC.  TZUTC undefined gives the default UTC
+		 * zonefile which usually does not take into account leap
+		 * seconds.  Define TZUTC to select your UTC zonefile which
+		 * does include leap seconds.  For example, with recent GNU
+		 * libc's:
+		 *    TZUTC=:/usr/share/zoneinfo/right/UTC
+		 */
+		setenv("TZ", getenv("TZUTC"), TRUE);
 		/*
 		 * Note: tzset() gets called implicitly by the time code,
 		 * but only the first time. When changing the environment

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH Make hwclock leap-second-aware
  2013-03-18  4:48 PATCH Make hwclock leap-second-aware Joseph Parmelee
@ 2013-03-18  9:48 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2013-03-18  9:48 UTC (permalink / raw)
  To: Joseph Parmelee; +Cc: util-linux

On Sun, Mar 17, 2013 at 10:48:57PM -0600, Joseph Parmelee wrote:
> --- sys-utils/hwclock.c.orig	2012-12-12 14:04:22.976355744 -0600
> +++ sys-utils/hwclock.c	2013-03-16 18:57:48.774606768 -0600

 Applied. (Please, use Signed-off-by: line in the commit message 
 next time.) 

 Thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-18  9:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18  4:48 PATCH Make hwclock leap-second-aware Joseph Parmelee
2013-03-18  9:48 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox