Function parseStringUnix

  • Parses a string into a CronUnix.

    Example

    parseStringUnix("* * * * *");
    // {
    // dayOfMonth: "*",
    // dayOfWeek: "*",
    // hours: "*",
    // minutes: "*",
    // month: "*",
    // }

    parseStringUnix("* * * * *");
    // {
    // dayOfMonth: "*",
    // dayOfWeek: "*",
    // hours: "*",
    // minutes: "*",
    // month: "*",
    // }

    parseStringUnix("1,2 1,2 1,2 1,2 1,2");
    // {
    // dayOfMonth: [1, 2],
    // dayOfWeek: [1, 2],
    // hours: [1, 2],
    // minutes: [1, 2],
    // month: [1, 2],
    // }

    parseStringUnix("1-2 1-2 1-2 1-2 1-2");
    // {
    // dayOfMonth: { from: 1, to: 2 },
    // dayOfWeek: { from: 1, to: 2 },
    // hours: { from: 1, to: 2 },
    // minutes: { from: 1, to: 2 },
    // month: { from: 1, to: 2 },
    // }

    parseStringUnix("1/2 1/2 1/2 1/2 1/2");
    // {
    // dayOfMonth: { every: 2, start: 1 },
    // dayOfWeek: { every: 2, start: 1 },
    // hours: { every: 2, start: 1 },
    // minutes: { every: 2, start: 1 },
    // month: { every: 2, start: 1 },
    // }

    parseStringUnix("1-2,3,4 * 2W SEP,OCT 1L");
    // {
    // dayOfMonth: { nearest: 2 },
    // dayOfWeek: { last: 1 },
    // hours: "*",
    // minutes: [{ from: 1, to: 2 }, 3, 4],
    // month: ["SEP", "OCT"],
    // }

    parseStringUnix("INVALID"); // undefined

    Returns

    A CronUnix or undefined if invalid.

    Parameters

    • source: string

      string to be parsed.

    Returns Maybe<CronUnix>