SIGforum.com    Main Page  Hop To Forum Categories  The Lounge    A nifty algorithm for date => day of week
Page 1 2 
Go
New
Find
Notify
Tools
Reply
  
A nifty algorithm for date => day of week Login/Join 
Member
Picture of wrightd
posted Hide Post
Yea I thot it was Friday, now I gotta go to work tomorrow. Dammit.




Lover of the US Constitution
Wile E. Coyote School of DIY Disaster
 
Posts: 9195 | Location: Nowhere the constitution is not honored | Registered: February 01, 2008Reply With QuoteReport This Post
His diet consists of black
coffee, and sarcasm.
Picture of egregore
posted Hide Post
If you work in a calendar factory, will they fire you for missing days?
 
Posts: 29166 | Location: Johnson City, TN | Registered: April 28, 2012Reply With QuoteReport This Post
Member
Picture of wrightd
posted Hide Post
Not if thems calendars be made in china.




Lover of the US Constitution
Wile E. Coyote School of DIY Disaster
 
Posts: 9195 | Location: Nowhere the constitution is not honored | Registered: February 01, 2008Reply With QuoteReport This Post
His diet consists of black
coffee, and sarcasm.
Picture of egregore
posted Hide Post
A long time ago on 60 Minutes, there was a savant guy who was his own algorithm. Give him any date at random and he could answer in less than 5 seconds and be right every time.
 
Posts: 29166 | Location: Johnson City, TN | Registered: April 28, 2012Reply With QuoteReport This Post
Baroque Bloke
Picture of Pipe Smoker
posted Hide Post
I create at least one testbench program for every function in my function library. That includes the function that I wrote that implements the Wang day-of-week (DoW) algorithm.

That testbench verified that my DoW function produced the correct weekday name for 30+ diverse dates. Not a bad test, but I thought it ought to be better.

After some thought, I figured out a way to write a testbench to check the DoW result for EVERY date in a specified span of dates.

I wrote that testbench and set it to test the DoW result for every date from 1582/10/15, the first date in the Gregorian calendar, through 2199/12/31, far in the future.

I’m glad I did – that testbench quickly found a wrong result. But after fixing one bug in my DoW function the testbench ran perfectly.

It reported that there were 235,433 dates in that span. Run time to generate all of those dates, and to check the DoW result for each date, was slightly more than 5 seconds.

I now have complete confidence in the Wang algorithm and my implementation of it. Very satisfying. Functions are programs small enough to be thoroughly tested. They make larger programs that use them simpler and more reliable.



Serious about crackers
 
Posts: 9754 | Location: San Diego | Registered: July 26, 2014Reply With QuoteReport This Post
  Powered by Social Strata Page 1 2  
 

SIGforum.com    Main Page  Hop To Forum Categories  The Lounge    A nifty algorithm for date => day of week

© SIGforum 2024