// 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 Duration = number & { readonly __brand: "Duration" };

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

