mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] __tm_to_time: fix last month
@ 2013-01-20 10:51 Hiltjo Posthuma
  0 siblings, 0 replies; only message in thread
From: Hiltjo Posthuma @ 2013-01-20 10:51 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

Hi!

I noticed there is possibly a typo in src/time/__tm_to_time.c

When calculating the day of year for december it uses 335 which should
be 334 I think.

Test case: http://pastebin.com/WBMfqXhp

I attached a patch as attachment.

Kind regards,
Hiltjo Posthuma

[-- Attachment #2: 0001-__tm_to_time-fix-last-month.patch --]
[-- Type: application/octet-stream, Size: 977 bytes --]

From 562a0b0ae7a4d294fca75bb776c8eeff8fff6d75 Mon Sep 17 00:00:00 2001
From: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 20 Jan 2013 11:44:28 +0100
Subject: [PATCH] __tm_to_time: fix last month

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
---
 src/time/__tm_to_time.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
 mode change 100644 => 100755 src/time/__tm_to_time.c

diff --git a/src/time/__tm_to_time.c b/src/time/__tm_to_time.c
old mode 100644
new mode 100755
index 3fa15fa..3b1140b
--- a/src/time/__tm_to_time.c
+++ b/src/time/__tm_to_time.c
@@ -26,7 +26,7 @@ time_t __tm_to_time(struct tm *tm)
 	z100 = Q(z4, 25);
 	z400 = Q(z100, 4);
 	day += year*365 + z4 - z100 + z400 +
-		month[(int []){0,31,59,90,120,151,181,212,243,273,304,335}];
+		month[(int []){0,31,59,90,120,151,181,212,243,273,304,334}];
 	return (long long)day*86400
 		+ tm->tm_hour*3600 + tm->tm_min*60 + tm->tm_sec
 		- -946684800; /* the dawn of time :) */
-- 
1.7.9


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-20 10:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-20 10:51 [PATCH] __tm_to_time: fix last month Hiltjo Posthuma

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).