mirror of
git://git.musl-libc.org/musl
synced 2024-11-23 18:14:19 +08:00
fix handling of negative offsets in timezone spec strings
previously, the hours were considered as a signed quantity while minutes and seconds were always treated as positive offsets. however, semantically the '-' sign should negate the whole hh:mm:ss offset. this bug only affected timezones east of GMT with non-whole-hours offsets, such as those used in India and Nepal.
This commit is contained in:
parent
a3763d64e0
commit
08b996d180
@ -36,19 +36,16 @@ static int getint(const char **p)
|
||||
return x;
|
||||
}
|
||||
|
||||
static int getsigned(const char **p)
|
||||
{
|
||||
if (**p == '-') {
|
||||
++*p;
|
||||
return -getint(p);
|
||||
}
|
||||
if (**p == '+') ++*p;
|
||||
return getint(p);
|
||||
}
|
||||
|
||||
static int getoff(const char **p)
|
||||
{
|
||||
int off = 3600*getsigned(p);
|
||||
int neg = 0;
|
||||
if (**p == '-') {
|
||||
++*p;
|
||||
neg = 1;
|
||||
} else if (**p == '+') {
|
||||
++*p;
|
||||
}
|
||||
int off = 3600*getint(p);
|
||||
if (**p == ':') {
|
||||
++*p;
|
||||
off += 60*getint(p);
|
||||
@ -57,7 +54,7 @@ static int getoff(const char **p)
|
||||
off += getint(p);
|
||||
}
|
||||
}
|
||||
return off;
|
||||
return neg ? -off : off;
|
||||
}
|
||||
|
||||
static void getrule(const char **p, int rule[5])
|
||||
|
Loading…
Reference in New Issue
Block a user