git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] Added "Z" as an alias for the timezone "UTC"

From
Marcus Comstedt <marcus@mc.pp.se>
Date
May 17, 2010, 19:07 UTC
Message-ID
<1274123231-18482-2-git-send-email-marcus@mc.pp.se>
In-Reply-To
<1274123231-18482-1-git-send-email-marcus@mc.pp.se>

The name "Z" for the UTC timezone is required to properly parse ISO 8601 times. Added it to the list of recignozed timezones.

Also, fixed the bug that timezone names shorter than 3 characters can never be matched by match_alpha(). Prior to the introduction of the "Z" zone, this affected the timezone "NT" (Nome).

Signed-off-by: Marcus Comstedt <marcus@mc.pp.se>
---
:100644 100644 002aa3c... 6bae49c... M	date.c
 date.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/date.c b/date.c
index 002aa3c..6bae49c 100644
--- a/date.c
+++ b/date.c
@@ -229,6 +229,7 @@ static const struct {
 
 	{ "GMT",    0, 0, },	/* Greenwich Mean */
 	{ "UTC",    0, 0, },	/* Universal (Coordinated) */
+	{ "Z",      0, 0, },    /* Zulu, alias for UTC */
 
 	{ "WET",    0, 0, },	/* Western European */
 	{ "BST",    0, 1, },	/* British Summer */
@@ -305,7 +306,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
 
 	for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
 		int match = match_string(date, timezone_names[i].name);
-		if (match >= 3) {
+		if (match >= 3 || match == strlen(timezone_names[i].name)) {
 			int off = timezone_names[i].offset;
 
 			/* This is bogus, but we like summer */
-- 
1.7.0.4
Previous: Marcus ComstedtNext: Jay Soffian
Message 2 of 6 in “PATCH: Improved support for ISO 8601 timezones”
  1. Marcus ComstedtMay 17, 2010
  2. 1/2 Added "Z" as an alias for the timezone "UTC"Marcus Comstedt, May 17, 2010
  3. Jay SoffianMay 17, 2010
  4. 2/2 Accept the timezone specifiers [+-]hh:mm and [+-]hh in addition to [+-]hhmmMarcus Comstedt, May 17, 2010
  5. Junio C HamanoMay 19, 2010
  6. Marcus ComstedtMay 19, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.