// Generated by bynkc — do not edit by hand.
// commons chrono.time

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "../../runtime.js";

/**
 * A length of time in milliseconds. Can be negative (representing past intervals).
 */
export type Span = number & { readonly __brand: "Span" };

export const Span = {
  of(value: number): Result<Span, ValidationError> {
    if (!Number.isInteger(value)) {
      return Err({ field: "Span", message: "must be an integer", value });
    }
    return Ok(value as Span);
  },
  unsafe(value: number): Span {
    return value as Span;
  },
  zero(): Span {
    return Span.unsafe(0);
  },
  isPositive(self: Span): boolean {
    return (self as number) > 0;
  },
  isZero(self: Span): boolean {
    return (self as number) === 0;
  },
};

