BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Robin · Convert a civil date into comparable day numbers

Convert a validated civil date into an ordinal, weekday and comparable day number.

Convert a civil date into comparable day numbers

Month lengths and century leap rules affect both date validation and weekday calculations. Resolve both from the same Gregorian day number. January 1, 1970 has day number 719163 and Monday-zero weekday 3. Century years follow the full Gregorian leap rule.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-robin.git
cd blyx-robin
blyxc native-run project.blyx -- 1970 1 1

API and return values

Returns [day number with 0001-01-01 = 1, Monday-zero weekday, day-of-year, days in month]. This is a calendar computation independent of machine locale. Invalid input returns an empty vector.

ArgumentAccepted input
yearpositive exact integer
monthpositive exact integer
daypositive exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
719163
3
1
31
Open in the full playground →

Practice

Change year = 1.0. Predict the result, then run the program.

Hint

Returns [day number with 0001-01-01 = 1, Monday-zero weekday, day-of-year, days in month]. This is a calendar computation independent of machine locale.

Worked solution

The result vector is [1, 0, 1, 31]. Compare its fields with the return layout in the API section.

Find

    let year = 1970.0;

Replace with

    let year = 1.0;

Output after the change

1
0
1
31