# Determine day of week using Zeller's congruence

## Recommended Posts

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.

zeller.vi

Neat!

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.

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

Neat!

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.

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...

Fixed! Now with smaller datatypes as well...

zeller2.vi

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...

Hi!

zeller2.vi and zeller.vi has different results.

zeller.vi has correct one.

Check today date 11may18 it is friday.

Thanks!

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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×

• #### Activity

• Wiki
×
• Create New...