BUPKIS
    Preparing search index...

    Variable DurationSchemaConst

    DurationSchema: ZodPipe<
        ZodCustomStringFormat<"duration">,
        ZodTransform<number, string>,
    > = ...

    A Zod schema that validates and transforms duration strings to milliseconds.

    This schema extends DurationFormatSchema by adding a transformation step that converts valid duration strings into their equivalent values in milliseconds. It supports the same flexible duration format but returns a numeric value representing the total duration in milliseconds.

    The transformation handles all supported time units with accurate conversions, except for months and years which use approximate values (30 days per month, 365 days per year) due to the variability of these units.

    Conversion rates:

    • 1 millisecond = 1 ms
    • 1 second = 1,000 ms
    • 1 minute = 60,000 ms
    • 1 hour = 3,600,000 ms
    • 1 day = 86,400,000 ms
    • 1 week = 604,800,000 ms
    • 1 month ≈ 2,592,000,000 ms (30 days)
    • 1 year ≈ 31,536,000,000 ms (365 days)
    DurationSchema.parse('1 hour'); // → 3600000
    DurationSchema.parse('30 minutes'); // → 1800000
    DurationSchema.parse('2 days'); // → 172800000
    DurationSchema.parse('500 ms'); // → 500
    DurationSchema.parse('1 week'); // → 604800000
    DurationSchema.parse('1 year'); // → 31536000000 (approximate)
    DurationSchema.parse('invalid'); // ✗ Throws - invalid format