mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] Remove unnecessary if in __secs_to_tm
@ 2021-02-28 15:09 Mattias Andrée
  2021-02-28 17:06 ` Rich Felker
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Mattias Andrée @ 2021-02-28 15:09 UTC (permalink / raw)
  To: musl; +Cc: Mattias Andrée

Since years divisible by 100 but not by 400 are not leap years,
q_cycles can at most be 24 (DAYS_PER_100Y / DAYS_PER_4Y == 24).
---
 src/time/__secs_to_tm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/time/__secs_to_tm.c b/src/time/__secs_to_tm.c
index 093d9021..2d0c0b2c 100644
--- a/src/time/__secs_to_tm.c
+++ b/src/time/__secs_to_tm.c
@@ -44,8 +44,7 @@ int __secs_to_tm(long long t, struct tm *tm)
 	remdays -= c_cycles * DAYS_PER_100Y;
 
 	q_cycles = remdays / DAYS_PER_4Y;
-	if (q_cycles == 25) q_cycles--;
-	remdays -= q_cycles * DAYS_PER_4Y;
+	remdays %= DAYS_PER_4Y;
 
 	remyears = remdays / 365;
 	if (remyears == 4) remyears--;
-- 
2.30.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-03-01 19:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28 15:09 [musl] [PATCH] Remove unnecessary if in __secs_to_tm Mattias Andrée
2021-02-28 17:06 ` Rich Felker
2021-02-28 17:24   ` Mattias Andrée
2021-02-28 17:34     ` Rich Felker
2021-02-28 19:22 ` [musl] [PATCH v2 1/2] " Mattias Andrée
2021-02-28 19:22   ` [musl] [PATCH v2 2/2] Use modulo instead of mul+sub " Mattias Andrée
2021-02-28 19:37     ` Szabolcs Nagy
2021-02-28 19:52       ` Mattias Andrée
2021-02-28 19:58       ` Jon Chesterfield
2021-03-01 19:26         ` Markus Wichmann
2021-02-28 19:27 ` [musl] [PATCH v3 1/2] Remove unnecessary if " Mattias Andrée
2021-02-28 19:27   ` [musl] [PATCH v3 2/2] Use modulo instead of mul+sub " Mattias Andrée

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).