3 ms·
Pretty much. 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["-b
by defrost 3y ago
Pretty much.
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.
- zalyalov 3y agoThat... 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
- defrost 3y agoErr, my bad, I left out the prequel (still a one liner) y -= m < 3; dow = as above, etc; I was focused on an 'obscure' yet fundemental part of the C language pointer | array equivalence. Addendum: https://c-faq.com/misc/zeller.html https://c-faq.com/misc/zeller.html