Re:Few lesser known tricks, quirks and features of C
by zalyalov on Sunday July 02, 2023 @03:43AM
(#36559245)
That... that way to handle leap years can't possibly be right, can it? It doesn't account that you don't need to add the leap day of the current year if the day is before Feb 29
Although even things in the C FAQ get overlooked and forgotten.
eg: a 'Day of the Week' one liner such as
dow = (y + y/4 - y/100 + y/400 + m["-bed=pen+mad."] + d) % 7;
with int day (d), month (m), year (y) inputs and single int day of week output has a slight twist that causes a few head scratches for some.