Calendar arithmetic
start plus span on the wall clock, with no time zone. 1. Years and months: the month count year × 12 + (month − 1) + years × 12 + months gives the target year and month; when start's day is past that month's length it becomes the month's last day (2024-01-31 + 1 month = 2024-02-29, 2023-02-28 + 1 year stays 02-28, 2024-02-29 + 1 year = 2025-02-28). The target year must be 1-9999. 2. Then (weeks × 7 + days) × 86,400 + hours × 3,600 + minutes × 60 + seconds, computed exactly (no overflow), is added as seconds, every day 86,400 seconds; the result must be from 0001-01-01T00:00:00 to 9999-12-31T23:59:59. Negative components subtract. start must be valid (year 1-9999, hour 0-23, minute and second 0-59). Otherwise none. Dates are proleptic Gregorian (leap years: divisible by 4, except centuries not divisible by 400).
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init time-add --lang rustcd time-add && 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-add: 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)35 lines›
package root:component;
world root {
import liberas:time/types@0.1.0;
export liberas:time/add@0.1.0;
}
package liberas:time@0.1.0 {
interface types {
record date-time {
year: s16,
month: u8,
day: u8,
hour: u8,
minute: u8,
second: u8,
}
}
interface add {
use types.{date-time};
record span {
years: s32,
months: s32,
weeks: s32,
days: s32,
hours: s64,
minutes: s64,
seconds: s64,
}
add: func(start: date-time, span: span) -> option<date-time>;
}
}
Test vectors17›
[
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 1,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 31,
"hour": 0,
"year": 2024,
"month": 1,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 1,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 29,
"hour": 0,
"year": 2024,
"month": 2,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 4,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 29,
"hour": 0,
"year": 2024,
"month": 2,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": -1,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 31,
"hour": 12,
"year": 2023,
"month": 3,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 1,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 1,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 31,
"hour": 0,
"year": 2024,
"month": 1,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": 1
},
"start": {
"day": 31,
"hour": 23,
"year": 2024,
"month": 12,
"minute": 59,
"second": 59
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 1,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 10,
"hour": 1,
"year": 2024,
"month": 3,
"minute": 30,
"second": 0
}
}
},
{
"args": {
"span": {
"days": -1,
"hours": 25,
"weeks": 52,
"years": 0,
"months": 0,
"minutes": -61,
"seconds": 3601
},
"start": {
"day": 1,
"hour": 0,
"year": 2000,
"month": 1,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": -1,
"months": 13,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 31,
"hour": 0,
"year": 2024,
"month": 5,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": -1
},
"start": {
"day": 1,
"hour": 0,
"year": 1,
"month": 1,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 31,
"hour": 23,
"year": 9999,
"month": 12,
"minute": 59,
"second": 59
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": 1
},
"start": {
"day": 31,
"hour": 23,
"year": 9999,
"month": 12,
"minute": 59,
"second": 59
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 5000,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 15,
"hour": 0,
"year": 5000,
"month": 6,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": -3000000,
"hours": 0,
"weeks": 0,
"years": 6000,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 15,
"hour": 0,
"year": 5000,
"month": 6,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": "-9223372036854775808",
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": "9223372036854775807"
},
"start": {
"day": 1,
"hour": 0,
"year": 2024,
"month": 1,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 30,
"hour": 0,
"year": 2024,
"month": 2,
"minute": 0,
"second": 0
}
}
},
{
"args": {
"span": {
"days": 0,
"hours": 0,
"weeks": 0,
"years": 0,
"months": 0,
"minutes": 0,
"seconds": 0
},
"start": {
"day": 1,
"hour": 0,
"year": 2024,
"month": 1,
"minute": 0,
"second": 60
}
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 17 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%.