{"record":{"id":"b17396404cbd8404","repo":"clockworklabs/SpacetimeDB","slug":"timestamp-is-outside-of-the-representable-range-of","errorCode":null,"errorMessage":"Timestamp is outside of the representable range of JS's Date","messagePattern":"Timestamp is outside of the representable range of JS's Date","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/lib/timestamp.ts","lineNumber":110,"sourceCode":"    const millis = date.getTime();\n    const micros = BigInt(millis) * Timestamp.MICROS_PER_MILLIS;\n    return new Timestamp(micros);\n  }\n\n  /**\n   * Get a `Date` representing approximately the same point in time as `this`.\n   *\n   * This method truncates to millisecond precision,\n   * and throws `RangeError` if the `Timestamp` is outside the range representable as a `Date`.\n   */\n  toDate(): Date {\n    const micros = this.__timestamp_micros_since_unix_epoch__;\n    const millis = micros / Timestamp.MICROS_PER_MILLIS;\n    if (\n      millis > BigInt(Number.MAX_SAFE_INTEGER) ||\n      millis < BigInt(Number.MIN_SAFE_INTEGER)\n    ) {\n      throw new RangeError(\n        \"Timestamp is outside of the representable range of JS's Date\"\n      );\n    }\n    return new Date(Number(millis));\n  }\n\n  /**\n   * Get an ISO 8601 / RFC 3339 formatted string representation of this timestamp with microsecond precision.\n   *\n   * This method preserves the full microsecond precision of the timestamp,\n   * and throws `RangeError` if the `Timestamp` is outside the range representable in ISO format.\n   *\n   * @returns ISO 8601 formatted string with microsecond precision (e.g., '2025-02-17T10:30:45.123456Z')\n   */\n  toISOString(): string {\n    const micros = this.__timestamp_micros_since_unix_epoch__;\n    const millis = micros / Timestamp.MICROS_PER_MILLIS;\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-typescript/src/lib/timestamp.ts#L92-L128","documentation":"The spacetimedb::duration!(...) proc-macro parses its input with humantime::parse_duration. String literals must be valid humantime durations (\"10s\", \"1h 30m\", \"500ms\"); integer literals are stringified to bare digits, which humantime rejects because they carry no unit. The syn error is spanned to the offending literal.","triggerScenarios":"spacetimedb::duration!(5) (integer, no unit) or duration!(\"5\"), duration!(\"1hr\"), duration!(\"10 seconds-ish\") — any literal humantime cannot parse.","commonSituations":"Assuming the macro takes a raw count of seconds/milliseconds; unit typos like 1hr instead of 1hour/1h; pasting durations from a config format with different syntax.","solutions":["Use a unit-suffixed string literal: spacetimedb::duration!(\"10s\").","For composite durations use humantime syntax: \"1h 30m\", \"2days 4h\".","Check humantime's accepted units: ns, us, ms, s/sec/seconds, m/min/minutes, h/hours, d/days (plus plurals)."],"exampleFix":"// before\nconst T: Duration = spacetimedb::duration!(500);      // bare int: no unit\nconst T: Duration = spacetimedb::duration!(\"1hr\");    // unknown unit\n\n// after\nconst T: Duration = spacetimedb::duration!(\"500ms\");\nconst T: Duration = spacetimedb::duration!(\"1h\");","handlingStrategy":"validation","validationCode":"# CI check: flag unit-less integers passed to the duration macro\nrg -n 'duration!\\(\\s*[0-9]+\\s*\\)' src/ && exit 1 || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote durations with a unit: duration!(\"10s\"), duration!(\"1h 30m\").","Remember integer literals are rejected because humantime requires an explicit unit.","Keep a cheat sheet of humantime units (ns/us/ms/s/m/h/d) next to macro usage."],"tags":["spacetimedb","proc-macro","duration","humantime","compile-time"],"backgroundTag":"invalid-duration-literal","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}