Skip to content

Commit

Permalink
Merge pull request #14 from earlephilhower/ugliertz
Browse files Browse the repository at this point in the history
Add support for <+/-nn> timezone names
  • Loading branch information
earlephilhower authored Nov 12, 2020
2 parents fc6534e + 27e5f4b commit 83b5db7
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions newlib/libc/time/tzset_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,25 @@ _DEFUN (_tzset_r, (reent_ptr),
if (*tzenv == ':')
++tzenv;

if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0)
if (tzenv[0] == '<')
{
TZ_UNLOCK;
return;
/* This is of the form "<[+-]nn>" so needs a different parsing */
if (sscanf (tzenv, "%9[^>]%n", __tzname_std, &n) <= 0)
{
TZ_UNLOCK;
return;
}
/* Include the final > and skip it */
strcat (__tzname_std, ">");
n++;
}
else
{
if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_std, &n) <= 0)
{
TZ_UNLOCK;
return;
}
}

tzenv += n;
Expand All @@ -83,16 +98,35 @@ _DEFUN (_tzset_r, (reent_ptr),
_tzname[0] = __tzname_std;
tzenv += n;

if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0)
{ /* No dst */
_tzname[1] = _tzname[0];
_timezone = tz->__tzrule[0].offset;
_daylight = 0;
TZ_UNLOCK;
return;
if (tzenv[0] == '<')
{
/* This is of the form "<[+-]nn>" so needs a different parsing */
if (sscanf (tzenv, "%9[^>]%n", __tzname_dst, &n) <= 0)
{ /* No dst */
_tzname[1] = _tzname[0];
_timezone = tz->__tzrule[0].offset;
_daylight = 0;
TZ_UNLOCK;
return;
}
/* Include the final > and skip it */
strcat (__tzname_dst, ">");
n++;
_tzname[1] = __tzname_dst;
}
else
_tzname[1] = __tzname_dst;
{
if (sscanf (tzenv, "%10[^0-9,+-]%n", __tzname_dst, &n) <= 0)
{ /* No dst */
_tzname[1] = _tzname[0];
_timezone = tz->__tzrule[0].offset;
_daylight = 0;
TZ_UNLOCK;
return;
}
else
_tzname[1] = __tzname_dst;
}

tzenv += n;

Expand Down

0 comments on commit 83b5db7

Please sign in to comment.