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

Clean up approxidate() in preparation for fixes

From
Linus Torvalds <torvalds@osdl.org>
Date
Sep 28, 2006, 19:12 UTC
Message-ID
<Pine.LNX.4.64.0609281211260.3952@g5.osdl.org>

Our approxidate cannot handle simple times like "5 PM yesterday", and to fix that, we will need to add some logic for number handling. This just splits that out into a function of its own (the same way the _real_ date parsing works).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---

This should change no code what-so-ever, just split it up in preparation for the next patch..

diff --git a/date.c b/date.c
index e387dcd..4ff6604 100644
--- a/date.c
+++ b/date.c
@@ -712,6 +712,15 @@ static const char *approxidate_alpha(con
 	return end;
 }
 
+static const char *approxidate_digit(const char *date, struct tm *tm, int *num)
+{
+	char *end;
+	unsigned long number = strtoul(date, &end, 10);
+
+	*num = number;
+	return end;
+}
+
 unsigned long approxidate(const char *date)
 {
 	int number = 0;
@@ -731,9 +740,7 @@ unsigned long approxidate(const char *da
 			break;
 		date++;
 		if (isdigit(c)) {
-			char *end;
-			number = strtoul(date-1, &end, 10);
-			date = end;
+			date = approxidate_digit(date-1, &tm, &number);
 			continue;
 		}
 		if (isalpha(c))
Next: Linus Torvalds
Message 1 of 9 in “Clean up approxidate() in preparation for fixes”
  1. Linus TorvaldsSep 28, 2006
  2. Fix approxidate() to understand more extended numbersLinus Torvalds, Sep 28, 2006
  3. Morten WelinderSep 29, 2006
  4. Linus TorvaldsSep 29, 2006
  5. Junio C HamanoSep 29, 2006
  6. Linus TorvaldsSep 29, 2006
  7. Junio C HamanoSep 29, 2006
  8. Johannes SchindelinSep 29, 2006
  9. Linus TorvaldsSep 29, 2006

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.