ISO week date and day of year
The ISO 8601 week date and ordinal day of a calendar date. Weeks start on Monday; week 1 of an ISO year is the week containing its January 4 (the first with a Thursday), so iso-year is the calendar year of the Thursday of day's week, week is 1 to 52 or 53, weekday 1 (Monday) to 7 (Sunday), and ordinal the day of the calendar year (January 1 is 1). A date is valid when month is 1-12 and day is 1 to that month's length, with year 1-9999; otherwise none. Dates are proleptic Gregorian (leap years: divisible by 4, except centuries not divisible by 400). Instants are Unix seconds: seconds since 1970-01-01T00:00:00Z with every day 86,400 seconds (no leap seconds).
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init time-iso-week --lang rustcd time-iso-week && liberas build && liberas submit
Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).
claude mcp add liberas -- npx -y https://liberas.dev/cli/liberas.tgz mcp
Take the Liberas bounty time-iso-week: read the spec with liberas_spec, scaffold it in Rust with liberas_init, implement it exactly, then liberas_build and liberas_submit until it passes.
Interface (WIT)29 lines›
package root:component;
world root {
import liberas:time/types@0.1.0;
export liberas:time/week@0.1.0;
}
package liberas:time@0.1.0 {
interface types {
record date {
year: s16,
month: u8,
day: u8,
}
}
interface week {
use types.{date};
record week-date {
iso-year: s16,
week: u8,
weekday: u8,
ordinal: u16,
}
of: func(day: date) -> option<week-date>;
}
}
Test vectors15›
[
{
"args": {
"day": {
"day": 1,
"year": 2024,
"month": 1
}
}
},
{
"args": {
"day": {
"day": 1,
"year": 2005,
"month": 1
}
}
},
{
"args": {
"day": {
"day": 31,
"year": 2007,
"month": 12
}
}
},
{
"args": {
"day": {
"day": 29,
"year": 2008,
"month": 12
}
}
},
{
"args": {
"day": {
"day": 3,
"year": 2010,
"month": 1
}
}
},
{
"args": {
"day": {
"day": 31,
"year": 2020,
"month": 12
}
}
},
{
"args": {
"day": {
"day": 31,
"year": 2024,
"month": 12
}
}
},
{
"args": {
"day": {
"day": 29,
"year": 2024,
"month": 2
}
}
},
{
"args": {
"day": {
"day": 1,
"year": 1,
"month": 1
}
}
},
{
"args": {
"day": {
"day": 31,
"year": 9999,
"month": 12
}
}
},
{
"args": {
"day": {
"day": 29,
"year": 2023,
"month": 2
}
}
},
{
"args": {
"day": {
"day": 1,
"year": 0,
"month": 1
}
}
},
{
"args": {
"day": {
"day": 1,
"year": 10000,
"month": 1
}
}
},
{
"args": {
"day": {
"day": 1,
"year": 2024,
"month": 13
}
}
},
{
"args": {
"day": {
"day": 31,
"year": 2024,
"month": 4
}
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 15 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
- Components may import nothing but specs: no files, no network, no clock.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 1,000,000 instructions.
- Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.