diff mbox series

[babeltrace,stable-1.5] Fix: timegm compat on Solaris

Message ID 1510603589-9901-1-git-send-email-mjeanson@efficios.com
State Accepted, archived
Delegated to: Jérémie Galarneau
Headers show
Series [babeltrace,stable-1.5] Fix: timegm compat on Solaris | expand

Commit Message

Michael Jeanson Nov. 13, 2017, 8:06 p.m. UTC
On Solaris 11 setting TZ to an empty string before calling mktime will
in some circumstances do the conversion in localtime instead of UTC as
expected.

Replace the empty string by "UTC".

Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
---
 include/babeltrace/compat/utc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jérémie Galarneau Nov. 13, 2017, 11:43 p.m. UTC | #1
Merged, thanks!

Jérémie

On 13 November 2017 at 15:06, Michael Jeanson <mjeanson at efficios.com> wrote:
> On Solaris 11 setting TZ to an empty string before calling mktime will
> in some circumstances do the conversion in localtime instead of UTC as
> expected.
>
> Replace the empty string by "UTC".
>
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
>  include/babeltrace/compat/utc.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/babeltrace/compat/utc.h b/include/babeltrace/compat/utc.h
> index d59d856..ab080f2 100644
> --- a/include/babeltrace/compat/utc.h
> +++ b/include/babeltrace/compat/utc.h
> @@ -67,8 +67,8 @@ time_t babeltrace_timegm(struct tm *tm)
>                 }
>         }
>
> -       /* Temporarily setting TZ to 1 for UTC */
> -       setenv("TZ", "", 1);
> +       /* Temporarily setting TZ to UTC */
> +       setenv("TZ", "UTC", 1);
>         tzset();
>         ret = mktime(tm);
>         if (tz) {
> --
> 2.7.4
>
diff mbox series

Patch

diff --git a/include/babeltrace/compat/utc.h b/include/babeltrace/compat/utc.h
index d59d856..ab080f2 100644
--- a/include/babeltrace/compat/utc.h
+++ b/include/babeltrace/compat/utc.h
@@ -67,8 +67,8 @@  time_t babeltrace_timegm(struct tm *tm)
 		}
 	}
 
-	/* Temporarily setting TZ to 1 for UTC */
-	setenv("TZ", "", 1);
+	/* Temporarily setting TZ to UTC */
+	setenv("TZ", "UTC", 1);
 	tzset();
 	ret = mktime(tm);
 	if (tz) {