xsebek / DoomsdayRule

Conway's weekday algorithm.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DoomsdayRule

This package implements the algorithm for determining the day of the week for any date.

The algorithm is was devised by the mathematician John Conway to be calculated mentally.

It's easy and uses remainders of 7 (because we only care about the weekday) to make big numbers small.

Command line trainer

There is a command line training program. You can run it with swift run or:

swift build
.build/debug/doomsday --help
# you can copy the binary to your $PATH
cp -f .build/debug/doomsday ~/.local/bin/
doomsday

Here is how the the REPL looks:

short REPL example

By typing more ? you will get more detailed explanation:

REPL explanation example

Don't worry if that explanation seems too complicated! You will rarely need to calculate the anchors for year and century, so only the last easy step is necessary.

About

Conway's weekday algorithm.


Languages

Language:Swift 100.0%