===
diff --git a/ChangeLog b/ChangeLog
index 7e530ef..e2cdbcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-03 Â P J P Â <pj.pandit@yahoo.co.in>
+
+ Â  Â  Â  [BZ #1077902]
+ Â  Â  Â  * time/gettimezone.c: new API to query POSIX TZ variable string.
+
Â 2014-04-02 Â Joseph Myers Â <joseph@codesourcery.com>

Â  Â  Â  Â  [BZ #16799]
diff --git a/time/Makefile b/time/Makefile
index b7f3dba..8bcc5ca 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -31,7 +31,7 @@ routines := offtime asctime clock ctime ctime_r difftime \
Â  Â  Â  Â  Â  Â  stime dysize timegm ftime Â  Â  Â  Â  Â  Â  Â  Â  Â  Â \
Â  Â  Â  Â  Â  Â  getdate strptime strptime_l Â  Â  Â  Â  Â  Â  Â  Â  Â \
Â  Â  Â  Â  Â  Â  strftime wcsftime strftime_l wcsftime_l Â  Â  Â \
- Â  Â  Â  Â  Â  timespec_get
+ Â  Â  Â  Â  Â  timespec_get gettimezone
Â aux := Â  Â  era alt_digit lc-time-cleanup

Â tests Â := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \

diff --git a/time/Versions b/time/Versions
index fd83818..957d2bf 100644
--- a/time/Versions
+++ b/time/Versions
@@ -25,7 +25,7 @@ libc {
Â  Â  Â ftime;

Â  Â  Â # g*
- Â  Â getitimer; gettimeofday; gmtime; gmtime_r;
+ Â  Â getitimer; gettimeofday; gmtime; gmtime_r; gettimezone;

Â  Â  Â # l*
Â  Â  Â localtime; localtime_r;
diff --git a/time/gettimezone.c b/time/gettimezone.c
new file mode 100644
index 0000000..88b2141
--- /dev/null
+++ b/time/gettimezone.c
@@ -0,0 +1,109 @@
+/* Copyright (C) 1991-2014 Free Software Foundation, Inc.
+ Â  This file is part of the GNU C Library.
+
+ Â  The GNU C Library is free software; you can redistribute it and/or
+ Â  modify it under the terms of the GNU Lesser General Public
+ Â  License as published by the Free Software Foundation; either
+ Â  version 2.1 of the License, or (at your option) any later version.
+
+ Â  The GNU C Library is distributed in the hope that it will be useful,
+ Â  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ Â  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Â See the GNU
+ Â  Lesser General Public License for more details.
+
+ Â  You should have received a copy of the GNU Lesser General Public
+ Â  License along with the GNU C Library; if not, see
+ Â  <http://www.gnu.org/licenses/>. Â */
+
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <timezone/tzfile.h>
+
+#define TZ_VERSION '2'
+#define TZ_FILE Â  Â "/etc/"TZDEFAULT
+
+
+/* gettimezone: reads local timezone definition from '/etc/localtime'
+ Â  and returns a POSIX TZ environment variable string or NULL in case
+ Â  of an error; See: tzfile(5), tzset(3).
+
+ Â  Â  Â  std offset dst [offset],start[/time],end[/time]
+
+ Â  Ex: TZ="NZST-12:00:00NZDT-13:00:00,M10.1.0,M3.3.0" Â */
+char *
+gettimezone (const char *tzname)
+{
+ Â  Â int n = 0;
+ Â  Â FILE *fp = NULL;
+ Â  Â char *tz = NULL, s[4];
+
+ Â  Â errno = 0;
+ Â  Â if (!tzname)
+ Â  Â  Â  Â tzname = TZ_FILE;
+
+ Â  Â fp = fopen (tzname, "rce");
+ Â  Â if (!fp)
+ Â  Â  Â  Â return tz;
+
+ Â  Â if (fread (s, sizeof (char), 4, fp) != 4)
+ Â  Â  Â  Â goto err;
+ Â  Â if (strncmp (TZ_MAGIC, s, 4))
+ Â  Â  Â  Â goto err;
+
+ Â  Â if (fread (s, sizeof (char), 1, fp) != 1)
+ Â  Â  Â  Â goto err;
+ Â  Â if (TZ_VERSION != *s && TZ_VERSION != (*s - 1))
+ Â  Â  Â  Â goto err;
+
+ Â  Â if (fseek (fp, -1, SEEK_END) < 0)
+ Â  Â  Â  Â goto err;
+ Â  Â if (fread (s, sizeof (char), 1, fp) != 1)
+ Â  Â  Â  Â goto err;
+ Â  Â if ('\n' != *s)
+ Â  Â  Â  Â goto err;
+
+ Â  Â n = -2;
+ Â  Â while (!fseek (fp, n, SEEK_END))
+ Â  Â {
+ Â  Â  Â  Â if (fread (s, sizeof (char), 1, fp) != 1)
+ Â  Â  Â  Â  Â  Â goto err;
+ Â  Â  Â  Â if ('\n' == *s)
+ Â  Â  Â  Â  Â  Â break;
+
+ Â  Â  Â  Â n--;
+ Â  Â }
+ Â  Â fseek (fp, ++n, SEEK_END);
+
+ Â  Â n = -(n + 1);
+ Â  Â tz = calloc (n, sizeof (char));
+ Â  Â if (!tz)
+ Â  Â  Â  Â goto err;
+
+ Â  Â if (fread (tz, sizeof (char), n, fp) != n)
+ Â  Â {
+ Â  Â  Â  Â free (tz);
+ Â  Â  Â  Â tz = NULL;
+ Â  Â }
+
+err:
+ Â  Â fclose (fp);
+ Â  Â return tz;
+}
+
+
+/* int
+main (int argc, char *argv[])
+{
+ Â  Â char *tz = NULL;
+
+ Â  Â tz = gettimezone (NULL);
+ Â  Â printf ("tz: %s\n", tz);
+ Â  Â if (tz)
+ Â  Â  Â  Â free (tz);
+
+ Â  Â return 0;
+} */
