Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
time / time-zone-to-localOpenRuns on Liberas

Instant to local time in an IANA zone

The wall-clock time in zone at the instant seconds. zone is a name in the IANA Time Zone Database release 2026e exactly as bundled in the Rust crate jiff-tzdb 0.1.9 (598 names: canonical zones and backward links such as Asia/Calcutta and US/Eastern, UTC, GMT, Etc/GMT+5, EST5EDT, Factory; compiled from the rearguard data), matched ASCII case-insensitively; any other name is unknown. Offsets, DST flags and abbreviations are that data's TZif records (RFC 8536): the transition table, the first local time type before the first transition, and the POSIX TZ footer rule after the last. offset-seconds is the UTC offset in force at that instant (local mean time offsets keep their seconds); local = seconds + offset-seconds as a date-time; dst and abbreviation are that local time type's isdst flag and designation. Instants are taken from -62135596800 (0001-01-01T00:00:00Z) to 253402128000 (9999-12-30T00:00:00Z) inclusive; outside that, for an unknown zone, or when the local year is outside 1-9999, the result is 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

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init time-zone-to-local --lang rust
cd time-zone-to-local && 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).

Interface (WIT)32 lines›
time-zone-to-local.wit
package root:component;

world root {
  import liberas:time/types@0.1.0;

  export liberas:time/zone-to-local@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 zone-to-local {
    use types.{date-time};

    record local-time {
      local: date-time,
      offset-seconds: s32,
      dst: bool,
      abbreviation: string,
    }

    to-local: func(seconds: s64, zone: string) -> option<local-time>;
  }
}
Test vectors24›
time-zone-to-local.cases.json
[
  {
    "args": {
      "zone": "UTC",
      "seconds": 0
    }
  },
  {
    "args": {
      "zone": "Asia/Seoul",
      "seconds": 1700000000
    }
  },
  {
    "args": {
      "zone": "America/New_York",
      "seconds": 1710054000
    }
  },
  {
    "args": {
      "zone": "America/New_York",
      "seconds": 1710053999
    }
  },
  {
    "args": {
      "zone": "america/new_york",
      "seconds": 1730613600
    }
  },
  {
    "args": {
      "zone": "US/Eastern",
      "seconds": 1730610000
    }
  },
  {
    "args": {
      "zone": "Europe/London",
      "seconds": 1719792000
    }
  },
  {
    "args": {
      "zone": "Europe/Dublin",
      "seconds": 1719792000
    }
  },
  {
    "args": {
      "zone": "Asia/Kolkata",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "Asia/Kathmandu",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "Australia/Lord_Howe",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "Pacific/Chatham",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "Etc/GMT+5",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "Asia/Seoul",
      "seconds": -2208988800
    }
  },
  {
    "args": {
      "zone": "Asia/Tokyo",
      "seconds": -62135596800
    }
  },
  {
    "args": {
      "zone": "Pacific/Kiritimati",
      "seconds": 253402128000
    }
  },
  {
    "args": {
      "zone": "Europe/Berlin",
      "seconds": 4102444800
    }
  },
  {
    "args": {
      "zone": "Asia/Calcutta",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "Factory",
      "seconds": 1704067200
    }
  },
  {
    "args": {
      "zone": "America/New_York",
      "seconds": -62135596800
    }
  },
  {
    "args": {
      "zone": "UTC",
      "seconds": -62135596801
    }
  },
  {
    "args": {
      "zone": "UTC",
      "seconds": 253402128001
    }
  },
  {
    "args": {
      "zone": "Mars/Olympus_Mons",
      "seconds": 0
    }
  },
  {
    "args": {
      "zone": "",
      "seconds": 0
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 24 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 2,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.