This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] time/time.h: CLOCK_EARTH


If leap seconds are abolished for leap hours, as has been repeately proposed, and
clocks remain in UTC, then the fact that the day is slightly shorter than 86400
seconds will slowly accumulate. Over time this will make UTC undesirable for
astronomical applications, such as sun-rise, sun-set, and solar noon.

Introduce CLOCK_EARTH, that for now is CLOCK_REALTIME, but may in the future become
UT1 (mean solar time at zero degrees longitute), so that these applications can mark
their need for an astronomical time, rather than "wall time". This will allow these
applications to supported in a forward-compatible manner, regardless of changes in
the definition of time.

If leap seconds are abolished a correct implementation of CLOCK_TAI could also be
provided, and perhaps a CLOCK_LORANC and CLOCK_GPS.

        * timezone/leapseconds: Update history.
        * sysdeps/unix/sysv/linux/bits/time.h: add CLOCK_EARTH.
        * sysdeps/unix/clock_gettime.c: make CLOCK_EARTH identical to CLOCK_REALTIME.
---
 sysdeps/unix/clock_gettime.c        | 6 ++++++
 sysdeps/unix/sysv/linux/bits/time.h | 8 ++++++--
 timezone/leapseconds                | 2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c
index 2975368..ddc4058 100644
--- a/sysdeps/unix/clock_gettime.c
+++ b/sysdeps/unix/clock_gettime.c
@@ -93,6 +93,12 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp)
 {
   int retval = -1;
 
+  /* UTC is currently tied to Earth time through use of leap seconds.  If this
+     changes in the future we can provide an implementation of UT1 in a forward
+     compatible way.  */
+  if (clock_id == CLOCK_EARTH)
+    clock_id = CLOCK_REALTIME;
+
   switch (clock_id)
     {
 #ifdef SYSDEP_GETTIME
diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
index 706946c..4b1094d 100644
--- a/sysdeps/unix/sysv/linux/bits/time.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -77,9 +77,13 @@ extern long int __sysconf (int);
 #   define CLOCK_REALTIME_ALARM		8
 /* Like CLOCK_BOOTTIME but also wakes suspended system.  */
 #   define CLOCK_BOOTTIME_ALARM		9
-/* Like CLOCK_REALTIME but in International Atomic Time.  */
+/* Like CLOCK_REALTIME but in International Atomic Time.
+ * GPS + 19  = TAI
+ * Loran-C + 28 = TAI
+ */
 #   define CLOCK_TAI			11
-
+/* Like CLOCK_REALTIME but always mean solar time of zero degrees long (maybe UT1). */
+#   define CLOCK_EARTH			12
 /* Flag to indicate time is absolute.  */
 #   define TIMER_ABSTIME		1
 #  endif
diff --git a/timezone/leapseconds b/timezone/leapseconds
index d6343c0..717a792 100644
--- a/timezone/leapseconds
+++ b/timezone/leapseconds
@@ -48,6 +48,8 @@ Leap	1997	Jun	30	23:59:60	+	S
 Leap	1998	Dec	31	23:59:60	+	S
 Leap	2005	Dec	31	23:59:60	+	S
 Leap	2008	Dec	31	23:59:60	+	S
+Leap	2012	Jun	30	23:59:60	+	S
+Leap	2015	Jun	30	23:59:60	+	S
 
 # INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
 #
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]