Day Of Week Calculator - Get xxxxDay for any given date ...

Share sample pubs, scripts, etc. with other NeoBook users

Moderator: Neosoft Support

Locked
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Day Of Week Calculator - Get xxxxDay for any given date ...

Post by Gaev »

Recently, in response to a request to be able to display dates in the form "xxxDay mmm/dd, ccyy", Sam whipped up a solution incorporating Hans-Peter's Gateway-Plugin to Lutz Mueller's newLISP dll.

If you are already using this combination of components in your pub, this is the best solution ; however, since a number of Developers do not (or can not) include this category of software in applications sold to their commercial clients, I sought alternate solutions.

The first thing that came to mind was JavaScript ...

var x = new Date(y,m,d)
vae DOW = x.getDay()

... this simple solution can be placed in a (dummy) html file, whose onLoad event would return the value of DOW in a (dummy) URL, that would be trapped by your Browser object's Before Navigation routine ; certainly doable, but not sure about the time delays.

So, I embarked on a purely NeoBook solution ; half way through a solution (that relied on a known Day Of The Week for a specified Date, and then calculating the number of days between this and the required date) ... as I was researching this on the web (Google), I came across a number of algorithms that you can use to determine the Day associated with any date ; in the Gregorian Calendar (> 1752 A.D.) at least.

So, I developed a bunch of Subroutines that computed one of these algorithms ; for the dozen or so dates I tested, it worked ; so, here ...

http://www.software-zone.com/neosoft/in ... &f=1&t=217

... is a pub that demonstrates the use of this routine

If you download it, please enter half a dozen varied dates in the included testing facility and verify that there are no flaws in this algorithm. Then ... Enjoy !
User avatar
Sam Cox
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Day Of Week Calculator

Post by Sam Cox »

Hi gk51,

The additional dates I tried with your DOW tools calculate correctly.  Nice work!  By the way, the algorithm you selected is virtually identical to the one I'm using.  I learned it years ago as Zeller's Congruence -- whatever a "congruence" is.

-- Sam

(Edited by Sam Cox at 2:30 pm on Feb. 12, 2004)
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Day Of Week Calculator

Post by Gaev »

Sam:

The additional dates I tried with your DOW tools calculate correctly.
Thanks

By the way, the algorithm you selected is virtually identical to the one I'm using.
I thought that a combination of newLisp's Date & Date-Value commands would have been an easy way of getting the Day Of Week ; may be, I should get past reading the newLisp manual and acquire some real live experience ... :-))

I learned it years ago as Zeller's Congruence -- whatever a "congruence" is.
A long time ago, I breezed through High School & University on the strength of my math skills ; but I couln't figure out how they came up with this formula ; good thing it works.
mh

Day Of Week Calculator

Post by mh »

gk51

Thanks for the great date routine. It works for me.

By the way would you please post your JavaScript Solution. I imagine that this type of a concept might work for other challanges and would very much appreciate seeing a sample from which to learn from.

MH
Locked