{"thread":{"id":"2968","subject":"Fix nasty approxidate bug","startedAt":"2006-01-05T03:33:55Z","lastAt":"2006-01-05T03:33:55Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"14170","messageId":"Pine.LNX.4.64.0601041930510.3169@g5.osdl.org","threadId":"2968","inReplyTo":null,"subject":"Fix nasty approxidate bug","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-01-05T03:33:55Z","receivedAt":"2006-01-05T03:33:55Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nStupid me.\n\nIf approxidate ends up with a month that is ahead of the current month, it \ndecrements the year to last year.\n\nWhich is correct, and means that \"last december\" does the right thing.\n\nHOWEVER. It should only do so if the year is the same as the current year.\n\nWithout this fix, \"5 days ago\" ends up being in 2004, because it first \ndecrements five days, getting us to December 2005 (correct), but then it \nalso ends up decrementing the year once more to turn that December into \n\"last year\" (incorrect, since it already _was_ last year).\n\nDuh. Pass me a donut.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/date.c b/date.c\nindex 3e11500..73037c7 100644\n--- a/date.c\n+++ b/date.c\n@@ -640,7 +640,7 @@ unsigned long approxidate(const char *da\n \t}\n \tif (number > 0 && number < 32)\n \t\ttm.tm_mday = number;\n-\tif (tm.tm_mon > now.tm_mon)\n+\tif (tm.tm_mon > now.tm_mon && tm.tm_year == now.tm_year)\n \t\ttm.tm_year--;\n \treturn mktime(&tm);\n }\n"}]}