Add "Z" as an alias for the timezone "UTC"
The name "Z" for the UTC timezone is required to properly parse ISO 8601 timestamps. Add it to the list of recognized timezones. Because timezone names can be shorter than 3 letters, loosen the restriction in match_alpha() that used to require at least 3 letters to match to allow a short timezone name as long as it matches exactly. Prior to the introduction of the "Z" zone, this already affected the timezone "NT" (Nome). Signed-off-by: Marcus Comstedt <marcus@mc.pp.se> Reviewed-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Marcus Comstedt committed
May 17, 2010 at 21:07 UTC
75b37e704781a9ae4db2f0beaaa023638c06490d
1 file changed
+2
-1
date.c
+2
-1
@@ -229,6 +229,7 @@ static const struct {
229
230
{ "GMT", 0, 0, }, /* Greenwich Mean */
231
{ "UTC", 0, 0, }, /* Universal (Coordinated) */
232
+ { "Z", 0, 0, }, /* Zulu, alias for UTC */
233
234
{ "WET", 0, 0, }, /* Western European */
235
{ "BST", 0, 1, }, /* British Summer */
@@ -305,7 +306,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
306
307
for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
308
int match = match_string(date, timezone_names[i].name);
308
- if (match >= 3) {
309
+ if (match >= 3 || match == strlen(timezone_names[i].name)) {
310
int off = timezone_names[i].offset;
311
312
/* This is bogus, but we like summer */