mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] use UTC instead of GMT
@ 2017-12-07 16:54 Natanael Copa
  2017-12-07 21:22 ` A. Wilcox
  2017-12-07 22:15 ` Natanael Copa
  0 siblings, 2 replies; 9+ messages in thread
From: Natanael Copa @ 2017-12-07 16:54 UTC (permalink / raw)
  To: musl; +Cc: Natanael Copa

GMT is a timezone officially used by some countries in Europe and
Africa. UTC is not a timezone, but a time standard. No country or
territory officialy uses UTC as local time.

Also, POSIX mentions UTC a few places[1][2] but never GMT (except as an
example[2] for a timezone)

So it makes more sense to use UTC instead of GMT and return UTC when no
timezone is set in /etc/localtime or TZ is set to empty.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/timezone.html
---
 src/time/__tz.c     | 16 ++++++++--------
 src/time/gmtime_r.c |  4 ++--
 src/time/timegm.c   |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/time/__tz.c b/src/time/__tz.c
index ffe8d402..8cc96032 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -15,7 +15,7 @@ weak_alias(__tzname, tzname);
 
 static char std_name[TZNAME_MAX+1];
 static char dst_name[TZNAME_MAX+1];
-const char __gmt[] = "GMT";
+const char __utc[] = "UTC";
 
 static int dst_off;
 static int r0[5], r1[5];
@@ -126,7 +126,7 @@ static void do_tzset()
 
 	s = getenv("TZ");
 	if (!s) s = "/etc/localtime";
-	if (!*s) s = __gmt;
+	if (!*s) s = __utc;
 
 	if (old_tz && !strcmp(s, old_tz)) return;
 
@@ -136,7 +136,7 @@ static void do_tzset()
 	 * free so as not to pull it into static programs. Growth
 	 * strategy makes it so free would have minimal benefit anyway. */
 	i = strlen(s);
-	if (i > PATH_MAX+1) s = __gmt, i = 3;
+	if (i > PATH_MAX+1) s = __utc, i = 3;
 	if (i >= old_tz_size) {
 		old_tz_size *= 2;
 		if (i >= old_tz_size) old_tz_size = i+1;
@@ -165,12 +165,12 @@ static void do_tzset()
 				}
 			}
 		}
-		if (!map) s = __gmt;
+		if (!map) s = __utc;
 	}
 	if (map && (map_size < 44 || memcmp(map, "TZif", 4))) {
 		__munmap((void *)map, map_size);
 		map = 0;
-		s = __gmt;
+		s = __utc;
 	}
 
 	zi = map;
@@ -207,7 +207,7 @@ static void do_tzset()
 				}
 			}
 			if (!__tzname[0]) __tzname[0] = __tzname[1];
-			if (!__tzname[0]) __tzname[0] = (char *)__gmt;
+			if (!__tzname[0]) __tzname[0] = (char *)__utc;
 			if (!__daylight) {
 				__tzname[1] = __tzname[0];
 				dst_off = __timezone;
@@ -216,7 +216,7 @@ static void do_tzset()
 		}
 	}
 
-	if (!s) s = __gmt;
+	if (!s) s = __utc;
 	getname(std_name, &s);
 	__tzname[0] = std_name;
 	__timezone = getoff(&s);
@@ -413,7 +413,7 @@ const char *__tm_to_tzname(const struct tm *tm)
 	const void *p = tm->__tm_zone;
 	LOCK(lock);
 	do_tzset();
-	if (p != __gmt && p != __tzname[0] && p != __tzname[1] &&
+	if (p != __utc && p != __tzname[0] && p != __tzname[1] &&
 	    (!zi || (uintptr_t)p-(uintptr_t)abbrevs >= abbrevs_end - abbrevs))
 		p = "";
 	UNLOCK(lock);
diff --git a/src/time/gmtime_r.c b/src/time/gmtime_r.c
index 8cbdadcb..cba72447 100644
--- a/src/time/gmtime_r.c
+++ b/src/time/gmtime_r.c
@@ -2,7 +2,7 @@
 #include <errno.h>
 #include "libc.h"
 
-extern const char __gmt[];
+extern const char __utc[];
 
 struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
 {
@@ -12,7 +12,7 @@ struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
 	}
 	tm->tm_isdst = 0;
 	tm->__tm_gmtoff = 0;
-	tm->__tm_zone = __gmt;
+	tm->__tm_zone = __utc;
 	return tm;
 }
 
diff --git a/src/time/timegm.c b/src/time/timegm.c
index b5dae8b6..f444e76e 100644
--- a/src/time/timegm.c
+++ b/src/time/timegm.c
@@ -2,7 +2,7 @@
 #include "time_impl.h"
 #include <errno.h>
 
-extern const char __gmt[];
+extern const char __utc[];
 
 time_t timegm(struct tm *tm)
 {
@@ -15,6 +15,6 @@ time_t timegm(struct tm *tm)
 	*tm = new;
 	tm->tm_isdst = 0;
 	tm->__tm_gmtoff = 0;
-	tm->__tm_zone = __gmt;
+	tm->__tm_zone = __utc;
 	return t;
 }
-- 
2.15.0



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

* Re: [PATCH] use UTC instead of GMT
  2017-12-07 16:54 [PATCH] use UTC instead of GMT Natanael Copa
@ 2017-12-07 21:22 ` A. Wilcox
  2017-12-07 22:15 ` Natanael Copa
  1 sibling, 0 replies; 9+ messages in thread
From: A. Wilcox @ 2017-12-07 21:22 UTC (permalink / raw)
  To: musl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 07/12/17 10:54, Natanael Copa wrote:
> GMT is a timezone officially used by some countries in Europe and 
> Africa. UTC is not a timezone, but a time standard. No country or 
> territory officialy uses UTC as local time.
> 
> Also, POSIX mentions UTC a few places[1][2] but never GMT (except
> as an example[2] for a timezone)
> 
> So it makes more sense to use UTC instead of GMT and return UTC
> when no timezone is set in /etc/localtime or TZ is set to empty.

Would just like to note here that the glib test suite gets really
confused by "GMT" instead of "UTC" because of silly daylight savings.

So not only is this more POSIXly correct, it will actually fix a bug.
 (Now I can probably remove tzdata as a test dependency of glib.)

- --arw

- -- 
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJaKbEvAAoJEMspy1GSK50UZoUP/REb06dcGAWlD8ltB96hf8oQ
IMRvXX7I3H/WUdTcOVcaJ8ligiunM50ijpoX9L+Dqe84cSu927DVzV9vgLibXcPO
RkhaZqIj8w/uJJKOXNKpTOXbU4YZgg0UHPaL5G6k5Lzz28gX5Wpq/KQO28WSkQFX
ObIDmcj8q5no8gh4R775OzSyrgSEN2xKvK1nNG5Xws6SLjRXO8F08CpL4uKVxkJr
pKHeFdfqhLOt4w0HpSUgcez+4sn8IzK1/97a26Tb6+t57VUyG5L+mkTr5qm6DEb4
sCslOyD5obglb7PsZtPxBUoRJBjQbnPbOXZMmqOuWsW1F2KqtYTP2G9Q0pNTLVI6
xl+9SY+rj6xmDxPYX2QSckpnFR0DhCS3BKvVKZRiLzZtejW1JK2kx5ve9hSNTIHq
E5r7Dt1bzF7IZ03JFrq9jkwlmWxu9ZHqFtvD6poSPRC1mZkiRNysr0I3XjuJkcBl
+M9YUeCWuGTZFgHqBYzjmzqBkXyf1O4Pcs1rJIDEgoesP2zFty54C6O+FcutTkcN
s+Fx51Uwq6fYNsmBeVPwHjt2ZA6s5rGLkpznW5DPZzrt4xsmqs0JTmqVCJ8AwICn
FZ1/b8+5IWNPUOJtGfF1WTk1By5D/+TuXYlei3+VV5YYzOp0M5evaOlszIn/pbuX
RfungIBYHdjbvZhk8JFR
=hbK5
-----END PGP SIGNATURE-----


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

* Re: [PATCH] use UTC instead of GMT
  2017-12-07 16:54 [PATCH] use UTC instead of GMT Natanael Copa
  2017-12-07 21:22 ` A. Wilcox
@ 2017-12-07 22:15 ` Natanael Copa
  1 sibling, 0 replies; 9+ messages in thread
From: Natanael Copa @ 2017-12-07 22:15 UTC (permalink / raw)
  To: musl

Whoops, this was an unintentional re-send. I posted this previously.

Sorry.

I still think still it would be nice to get it applied as it fixes some
annoyances.

-nc

On Thu,  7 Dec 2017 17:54:07 +0100
Natanael Copa <ncopa@alpinelinux.org> wrote:

> GMT is a timezone officially used by some countries in Europe and
> Africa. UTC is not a timezone, but a time standard. No country or
> territory officialy uses UTC as local time.
> 
> Also, POSIX mentions UTC a few places[1][2] but never GMT (except as an
> example[2] for a timezone)
> 
> So it makes more sense to use UTC instead of GMT and return UTC when no
> timezone is set in /etc/localtime or TZ is set to empty.
> 
> [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html
> [2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/timezone.html
> ---
>  src/time/__tz.c     | 16 ++++++++--------
>  src/time/gmtime_r.c |  4 ++--
>  src/time/timegm.c   |  4 ++--
>  3 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/src/time/__tz.c b/src/time/__tz.c
> index ffe8d402..8cc96032 100644
> --- a/src/time/__tz.c
> +++ b/src/time/__tz.c
> @@ -15,7 +15,7 @@ weak_alias(__tzname, tzname);
>  
>  static char std_name[TZNAME_MAX+1];
>  static char dst_name[TZNAME_MAX+1];
> -const char __gmt[] = "GMT";
> +const char __utc[] = "UTC";
>  
>  static int dst_off;
>  static int r0[5], r1[5];
> @@ -126,7 +126,7 @@ static void do_tzset()
>  
>  	s = getenv("TZ");
>  	if (!s) s = "/etc/localtime";
> -	if (!*s) s = __gmt;
> +	if (!*s) s = __utc;
>  
>  	if (old_tz && !strcmp(s, old_tz)) return;
>  
> @@ -136,7 +136,7 @@ static void do_tzset()
>  	 * free so as not to pull it into static programs. Growth
>  	 * strategy makes it so free would have minimal benefit anyway. */
>  	i = strlen(s);
> -	if (i > PATH_MAX+1) s = __gmt, i = 3;
> +	if (i > PATH_MAX+1) s = __utc, i = 3;
>  	if (i >= old_tz_size) {
>  		old_tz_size *= 2;
>  		if (i >= old_tz_size) old_tz_size = i+1;
> @@ -165,12 +165,12 @@ static void do_tzset()
>  				}
>  			}
>  		}
> -		if (!map) s = __gmt;
> +		if (!map) s = __utc;
>  	}
>  	if (map && (map_size < 44 || memcmp(map, "TZif", 4))) {
>  		__munmap((void *)map, map_size);
>  		map = 0;
> -		s = __gmt;
> +		s = __utc;
>  	}
>  
>  	zi = map;
> @@ -207,7 +207,7 @@ static void do_tzset()
>  				}
>  			}
>  			if (!__tzname[0]) __tzname[0] = __tzname[1];
> -			if (!__tzname[0]) __tzname[0] = (char *)__gmt;
> +			if (!__tzname[0]) __tzname[0] = (char *)__utc;
>  			if (!__daylight) {
>  				__tzname[1] = __tzname[0];
>  				dst_off = __timezone;
> @@ -216,7 +216,7 @@ static void do_tzset()
>  		}
>  	}
>  
> -	if (!s) s = __gmt;
> +	if (!s) s = __utc;
>  	getname(std_name, &s);
>  	__tzname[0] = std_name;
>  	__timezone = getoff(&s);
> @@ -413,7 +413,7 @@ const char *__tm_to_tzname(const struct tm *tm)
>  	const void *p = tm->__tm_zone;
>  	LOCK(lock);
>  	do_tzset();
> -	if (p != __gmt && p != __tzname[0] && p != __tzname[1] &&
> +	if (p != __utc && p != __tzname[0] && p != __tzname[1] &&
>  	    (!zi || (uintptr_t)p-(uintptr_t)abbrevs >= abbrevs_end - abbrevs))
>  		p = "";
>  	UNLOCK(lock);
> diff --git a/src/time/gmtime_r.c b/src/time/gmtime_r.c
> index 8cbdadcb..cba72447 100644
> --- a/src/time/gmtime_r.c
> +++ b/src/time/gmtime_r.c
> @@ -2,7 +2,7 @@
>  #include <errno.h>
>  #include "libc.h"
>  
> -extern const char __gmt[];
> +extern const char __utc[];
>  
>  struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
>  {
> @@ -12,7 +12,7 @@ struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
>  	}
>  	tm->tm_isdst = 0;
>  	tm->__tm_gmtoff = 0;
> -	tm->__tm_zone = __gmt;
> +	tm->__tm_zone = __utc;
>  	return tm;
>  }
>  
> diff --git a/src/time/timegm.c b/src/time/timegm.c
> index b5dae8b6..f444e76e 100644
> --- a/src/time/timegm.c
> +++ b/src/time/timegm.c
> @@ -2,7 +2,7 @@
>  #include "time_impl.h"
>  #include <errno.h>
>  
> -extern const char __gmt[];
> +extern const char __utc[];
>  
>  time_t timegm(struct tm *tm)
>  {
> @@ -15,6 +15,6 @@ time_t timegm(struct tm *tm)
>  	*tm = new;
>  	tm->tm_isdst = 0;
>  	tm->__tm_gmtoff = 0;
> -	tm->__tm_zone = __gmt;
> +	tm->__tm_zone = __utc;
>  	return t;
>  }



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

* Re: [PATCH] use UTC instead of GMT
  2017-07-28 14:05       ` A. Wilcox
@ 2017-07-28 14:54         ` Rich Felker
  0 siblings, 0 replies; 9+ messages in thread
From: Rich Felker @ 2017-07-28 14:54 UTC (permalink / raw)
  To: musl

On Fri, Jul 28, 2017 at 09:05:34AM -0500, A. Wilcox wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> On 28/07/17 08:00, Rich Felker wrote:
> > On Fri, Jul 28, 2017 at 02:35:10PM +0200, Natanael Copa wrote:
> >> I checked what FreeBSD, OpenBSD and GNU/Linux does when timezone
> >> is unset. Seems that they all use "UTC" so I think that makes
> >> most sense.
> > 
> > That may well end up being the reasonable position. Let's see what 
> > others have to say on the matter (hopefully without it getting too 
> > much into bikeshedding).
> 
> 
> +100
> 
> That is the sane and reasonable thing to do and the fact musl doesn't
> do that automatically has broken two kernel builds for me (minor
> annoyance, but still a real issue).  The kernels boot but uname -a
> says "Sat Sep 13 23:57:23 Time zone not s" which cuts off the year.
> May seem silly but having to use Wolfram Alpha to calculate what year
> the 13th of September fell on a Saturday is a bit annoying when you're
> dealing with servers with long uptimes...
> 
> (The answer is 2014 and I pulled that from an old log.  Don't worry,
> I'm not actually running anything that old on anything.)

Do you know how the kernel ended up with "Time zone not s[et?]" there?
This seems like a separate bug that should be addressed somewhere.

Rich


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

* Re: [PATCH] use UTC instead of GMT
  2017-07-28 13:00     ` Rich Felker
@ 2017-07-28 14:05       ` A. Wilcox
  2017-07-28 14:54         ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: A. Wilcox @ 2017-07-28 14:05 UTC (permalink / raw)
  To: musl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 28/07/17 08:00, Rich Felker wrote:
> On Fri, Jul 28, 2017 at 02:35:10PM +0200, Natanael Copa wrote:
>> I checked what FreeBSD, OpenBSD and GNU/Linux does when timezone
>> is unset. Seems that they all use "UTC" so I think that makes
>> most sense.
> 
> That may well end up being the reasonable position. Let's see what 
> others have to say on the matter (hopefully without it getting too 
> much into bikeshedding).


+100

That is the sane and reasonable thing to do and the fact musl doesn't
do that automatically has broken two kernel builds for me (minor
annoyance, but still a real issue).  The kernels boot but uname -a
says "Sat Sep 13 23:57:23 Time zone not s" which cuts off the year.
May seem silly but having to use Wolfram Alpha to calculate what year
the 13th of September fell on a Saturday is a bit annoying when you're
dealing with servers with long uptimes...

(The answer is 2014 and I pulled that from an old log.  Don't worry,
I'm not actually running anything that old on anything.)


Best regards,
- --arw


- -- 
A. Wilcox (awilfox)
Project Lead, Adélie Linux
http://adelielinux.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJZe0SmAAoJEMspy1GSK50UWgIQAIaMb95cQ9jdFl6pwTKTXH7b
iQSBHNLXoVY+VpHwfLDyKlULs7mr96zlcdiI9iiZNLg+0iosOaW1u1HZpFV8wiSv
cm1WmDQuJhB7gTrj9Ydss3/LbBRbz8zxkgDOWqJD1SPZS15zkftX0hZsOqdbn4nT
sJeh8Ucuo89TUZ+FMHNL0fttSLSMIws+Cyk10sucxe2tfMy1PpmFMMv8khsevlsF
/Jhdj66bUI5FBTPC6cxLbYiGXYZI4IzAv1L7DPH2HT954Hb+5vptFaD5Bmktty+u
Xn19SgTnXp8KVQhySmUr02EyfJ/ZaNcN4jUwZxes6B5sGRJLAXtyRwXCy7LNNOjN
ZBj8np+k7hQdzfsRosB3ZbEpD1kAib+pMQfcomrKilSpDV+IcmEBXOcdRcoNZVaY
aON6DuzbXlVutt/W7k4XcSURkltK6C7lDjb9rbVRYr5CBkLY8yje4NQCY0xWHUWM
ke5qPivzr4fJZSKSi3nOPGm8YyumEBEvP5vHdynwRO8WYno512ag1dJVbTTarLYc
pISIB5mhrvlMGdPeDfBSVa6wtLdMHstIlmd57+aM+QPF/t8C2LUFf6sRadOxudlt
Cj50CDV3Y6HeNUw8sH/boRGVwd/HZmoR5NPnRsAObMdcdQtmJkCY7GLZazZl1ZXa
pfqgR082/TDNhUa80MHa
=Bx7q
-----END PGP SIGNATURE-----


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

* Re: [PATCH] use UTC instead of GMT
  2017-07-28 12:35   ` Natanael Copa
@ 2017-07-28 13:00     ` Rich Felker
  2017-07-28 14:05       ` A. Wilcox
  0 siblings, 1 reply; 9+ messages in thread
From: Rich Felker @ 2017-07-28 13:00 UTC (permalink / raw)
  To: musl

On Fri, Jul 28, 2017 at 02:35:10PM +0200, Natanael Copa wrote:
> On Sat, 22 Jul 2017 10:26:25 -0400
> Rich Felker <dalias@libc.org> wrote:
> 
> > On Sat, Jul 22, 2017 at 11:19:03AM +0200, Natanael Copa wrote:
> > > GMT is a timezone officially used by some countries in Europe and
> > > Africa. UTC is not a timezone, but a time standard. No country or
> > > territory officialy uses UTC as local time.
> > > 
> > > Also, POSIX mentions UTC a few places[1][2] but never GMT (except as an
> > > example[2] for a timezone)
> > > 
> > > So it makes more sense to use UTC instead of GMT and return UTC when no
> > > timezone is set in /etc/localtime or TZ is set to empty.
> > > 
> > > [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html
> > > [2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/timezone.html
> > > ---
> > > 
> > > This causes real problems for people:
> > > https://github.com/gliderlabs/docker-alpine/issues/310#issuecomment-316732179
> > 
> > The motivation for the naming was that POSIX "UTC" is not actually UTC
> > but something like UT1 or modified UTC more akin to historical GMT.
> 
> Do you have any references on that?

The definition of seconds since the epoch defines 86400-second
calendar days:

http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_16

> > You can certainly get it to show "UTC" just by setting TZ=UTC, but
> > if users are actually hitting problems from this it should be reviewed
> > whether the behavior still makes sense.
> 
> The problem at hand seems to be that some docker image used hardcoded
> timezone to EST so they added automatic tests to verify that timezone
> is UTC.

This seems like the real bug...

> So tests broke on Alpine. To fix that it seems like they set the
> timezone via TZ=UTC variable, and that broke things for users who set
> the timezone via /etc/localtime.
> 
> Basically lot of minor fuzz, which all can easily be worked around, but
> its just annoying.
> 
> I checked what FreeBSD, OpenBSD and GNU/Linux does when timezone is
> unset. Seems that they all use "UTC" so I think that makes most sense.

That may well end up being the reasonable position. Let's see what
others have to say on the matter (hopefully without it getting too
much into bikeshedding).

Rich


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

* Re: [PATCH] use UTC instead of GMT
  2017-07-22 14:26 ` Rich Felker
@ 2017-07-28 12:35   ` Natanael Copa
  2017-07-28 13:00     ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: Natanael Copa @ 2017-07-28 12:35 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

On Sat, 22 Jul 2017 10:26:25 -0400
Rich Felker <dalias@libc.org> wrote:

> On Sat, Jul 22, 2017 at 11:19:03AM +0200, Natanael Copa wrote:
> > GMT is a timezone officially used by some countries in Europe and
> > Africa. UTC is not a timezone, but a time standard. No country or
> > territory officialy uses UTC as local time.
> > 
> > Also, POSIX mentions UTC a few places[1][2] but never GMT (except as an
> > example[2] for a timezone)
> > 
> > So it makes more sense to use UTC instead of GMT and return UTC when no
> > timezone is set in /etc/localtime or TZ is set to empty.
> > 
> > [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html
> > [2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/timezone.html
> > ---
> > 
> > This causes real problems for people:
> > https://github.com/gliderlabs/docker-alpine/issues/310#issuecomment-316732179
> 
> The motivation for the naming was that POSIX "UTC" is not actually UTC
> but something like UT1 or modified UTC more akin to historical GMT.

Do you have any references on that?

> You can certainly get it to show "UTC" just by setting TZ=UTC, but
> if users are actually hitting problems from this it should be reviewed
> whether the behavior still makes sense.

The problem at hand seems to be that some docker image used hardcoded
timezone to EST so they added automatic tests to verify that timezone
is UTC.

So tests broke on Alpine. To fix that it seems like they set the
timezone via TZ=UTC variable, and that broke things for users who set
the timezone via /etc/localtime.

Basically lot of minor fuzz, which all can easily be worked around, but
its just annoying.

I checked what FreeBSD, OpenBSD and GNU/Linux does when timezone is
unset. Seems that they all use "UTC" so I think that makes most sense.



> 
> Rich



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

* Re: [PATCH] use UTC instead of GMT
  2017-07-22  9:19 Natanael Copa
@ 2017-07-22 14:26 ` Rich Felker
  2017-07-28 12:35   ` Natanael Copa
  0 siblings, 1 reply; 9+ messages in thread
From: Rich Felker @ 2017-07-22 14:26 UTC (permalink / raw)
  To: musl

On Sat, Jul 22, 2017 at 11:19:03AM +0200, Natanael Copa wrote:
> GMT is a timezone officially used by some countries in Europe and
> Africa. UTC is not a timezone, but a time standard. No country or
> territory officialy uses UTC as local time.
> 
> Also, POSIX mentions UTC a few places[1][2] but never GMT (except as an
> example[2] for a timezone)
> 
> So it makes more sense to use UTC instead of GMT and return UTC when no
> timezone is set in /etc/localtime or TZ is set to empty.
> 
> [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html
> [2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/timezone.html
> ---
> 
> This causes real problems for people:
> https://github.com/gliderlabs/docker-alpine/issues/310#issuecomment-316732179

The motivation for the naming was that POSIX "UTC" is not actually UTC
but something like UT1 or modified UTC more akin to historical GMT.
You can certainly get it to show "UTC" just by setting TZ=UTC, but
if users are actually hitting problems from this it should be reviewed
whether the behavior still makes sense.

Rich


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

* [PATCH] use UTC instead of GMT
@ 2017-07-22  9:19 Natanael Copa
  2017-07-22 14:26 ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: Natanael Copa @ 2017-07-22  9:19 UTC (permalink / raw)
  To: musl; +Cc: Natanael Copa

GMT is a timezone officially used by some countries in Europe and
Africa. UTC is not a timezone, but a time standard. No country or
territory officialy uses UTC as local time.

Also, POSIX mentions UTC a few places[1][2] but never GMT (except as an
example[2] for a timezone)

So it makes more sense to use UTC instead of GMT and return UTC when no
timezone is set in /etc/localtime or TZ is set to empty.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime.html
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/timezone.html
---

This causes real problems for people:
https://github.com/gliderlabs/docker-alpine/issues/310#issuecomment-316732179

 src/time/__tz.c     | 16 ++++++++--------
 src/time/gmtime_r.c |  4 ++--
 src/time/timegm.c   |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/time/__tz.c b/src/time/__tz.c
index ffe8d402..8cc96032 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -15,7 +15,7 @@ weak_alias(__tzname, tzname);
 
 static char std_name[TZNAME_MAX+1];
 static char dst_name[TZNAME_MAX+1];
-const char __gmt[] = "GMT";
+const char __utc[] = "UTC";
 
 static int dst_off;
 static int r0[5], r1[5];
@@ -126,7 +126,7 @@ static void do_tzset()
 
 	s = getenv("TZ");
 	if (!s) s = "/etc/localtime";
-	if (!*s) s = __gmt;
+	if (!*s) s = __utc;
 
 	if (old_tz && !strcmp(s, old_tz)) return;
 
@@ -136,7 +136,7 @@ static void do_tzset()
 	 * free so as not to pull it into static programs. Growth
 	 * strategy makes it so free would have minimal benefit anyway. */
 	i = strlen(s);
-	if (i > PATH_MAX+1) s = __gmt, i = 3;
+	if (i > PATH_MAX+1) s = __utc, i = 3;
 	if (i >= old_tz_size) {
 		old_tz_size *= 2;
 		if (i >= old_tz_size) old_tz_size = i+1;
@@ -165,12 +165,12 @@ static void do_tzset()
 				}
 			}
 		}
-		if (!map) s = __gmt;
+		if (!map) s = __utc;
 	}
 	if (map && (map_size < 44 || memcmp(map, "TZif", 4))) {
 		__munmap((void *)map, map_size);
 		map = 0;
-		s = __gmt;
+		s = __utc;
 	}
 
 	zi = map;
@@ -207,7 +207,7 @@ static void do_tzset()
 				}
 			}
 			if (!__tzname[0]) __tzname[0] = __tzname[1];
-			if (!__tzname[0]) __tzname[0] = (char *)__gmt;
+			if (!__tzname[0]) __tzname[0] = (char *)__utc;
 			if (!__daylight) {
 				__tzname[1] = __tzname[0];
 				dst_off = __timezone;
@@ -216,7 +216,7 @@ static void do_tzset()
 		}
 	}
 
-	if (!s) s = __gmt;
+	if (!s) s = __utc;
 	getname(std_name, &s);
 	__tzname[0] = std_name;
 	__timezone = getoff(&s);
@@ -413,7 +413,7 @@ const char *__tm_to_tzname(const struct tm *tm)
 	const void *p = tm->__tm_zone;
 	LOCK(lock);
 	do_tzset();
-	if (p != __gmt && p != __tzname[0] && p != __tzname[1] &&
+	if (p != __utc && p != __tzname[0] && p != __tzname[1] &&
 	    (!zi || (uintptr_t)p-(uintptr_t)abbrevs >= abbrevs_end - abbrevs))
 		p = "";
 	UNLOCK(lock);
diff --git a/src/time/gmtime_r.c b/src/time/gmtime_r.c
index 8cbdadcb..cba72447 100644
--- a/src/time/gmtime_r.c
+++ b/src/time/gmtime_r.c
@@ -2,7 +2,7 @@
 #include <errno.h>
 #include "libc.h"
 
-extern const char __gmt[];
+extern const char __utc[];
 
 struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
 {
@@ -12,7 +12,7 @@ struct tm *__gmtime_r(const time_t *restrict t, struct tm *restrict tm)
 	}
 	tm->tm_isdst = 0;
 	tm->__tm_gmtoff = 0;
-	tm->__tm_zone = __gmt;
+	tm->__tm_zone = __utc;
 	return tm;
 }
 
diff --git a/src/time/timegm.c b/src/time/timegm.c
index b5dae8b6..f444e76e 100644
--- a/src/time/timegm.c
+++ b/src/time/timegm.c
@@ -2,7 +2,7 @@
 #include "time_impl.h"
 #include <errno.h>
 
-extern const char __gmt[];
+extern const char __utc[];
 
 time_t timegm(struct tm *tm)
 {
@@ -15,6 +15,6 @@ time_t timegm(struct tm *tm)
 	*tm = new;
 	tm->tm_isdst = 0;
 	tm->__tm_gmtoff = 0;
-	tm->__tm_zone = __gmt;
+	tm->__tm_zone = __utc;
 	return t;
 }
-- 
2.13.2



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

end of thread, other threads:[~2017-12-07 22:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-07 16:54 [PATCH] use UTC instead of GMT Natanael Copa
2017-12-07 21:22 ` A. Wilcox
2017-12-07 22:15 ` Natanael Copa
  -- strict thread matches above, loose matches on Subject: below --
2017-07-22  9:19 Natanael Copa
2017-07-22 14:26 ` Rich Felker
2017-07-28 12:35   ` Natanael Copa
2017-07-28 13:00     ` Rich Felker
2017-07-28 14:05       ` A. Wilcox
2017-07-28 14:54         ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).