Jump to content

Determine day of week using Zeller's congruence


Recommended Posts

Posted

I know the LV timestamp engine could easily be used to determine the day of the weak for a specific date. However, for those interested in a "behind the scenes" solution... the Zeller algorithm is really nice and possibly more optimized for certain applications.

 

8wwfh4.gif

zeller.vi

Posted

Neat!  :thumbup1:

 

I see a prime candidate for Coerce to Type in there; this, and removing the decrement by pulling the ENUM output before the increment could tidy up that last bit of syntax.

Posted
Neat!  :thumbup1:

 

I see a prime candidate for Coerce to Type in there; this, and removing the decrement by pulling the ENUM output before the increment could tidy up that last bit of syntax.

 

+1 -1 that's so funny... after I read your reply, I still needed some seconds to find this lame operation! +1 Kudo for the Coerce to Type operator. This situation seems to appear almost every state-machine-like VI!

 

 

...... and here's the Sakamoto method.

 

attachicon.gifdOW.png

 

A little bit afraid to say... but... the c code looks so much more readable in your example! I mean it makes me afraid because this kind of comment lends itself very easily into love-hate posts...

Posted

the c code looks so much more readable in your example!

Sure. Sometimes.Although unless you have programed in C you might think y -= m < 3 is rather obtuse.

 

I'd defy anyone to say that string formatting in C is "more readable" though.

  • 5 years later...
Posted
On 5/11/2018 at 2:56 PM, mahgust said:

Hi!

zeller2.vi and zeller.vi has different results.

zeller.vi has correct one.

Check today date 11may18 it is friday.

 

Thanks!

The difference is in the second Q&R function, where version 2 converts the remainder to U16 instead of the quotient.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.