A tiny New Year's programming challenge
|
01-06-2015, 04:11 PM
Post: #15
|
|||
|
|||
RE: A tiny New Year's programming challenge
As to making the check more elegant: all I have been able to come up with so far is to try and test for Mondays instead of Thursdays, if the DOW routine returns 0. for Mondays, that is.
A year has 53 weeks if and only if it starts or ends with a Thursday. A year that starts with a Thursday means 2.02yyyy will be a Monday. For a year that ends with a Thursday: Unfortunately, no xx.xxyyyy for x=3..12 (and Jan and Feb of y+1) are Mondays. No aa.bbyyyy exists for which both aa.bbyyyy and bb.aayyyy are Mondays (so that we can stay independent from the date setting). So I test 2.02yy+1 for a Tuesday instead.. Here's the two subroutines for 48/49/50 compatibles: Code: @ Day Of Week (as a number) Code: @ number of weeks in year Y Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)