CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-cronstrue

tessl install tessl/npm-cronstrue@3.2.0

Convert cron expressions into human readable descriptions

Agent Success

Agent success rate when using this tile

100%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.12x

Baseline

Agent success rate without this tile

89%

task.mdevals/scenario-4/

Cron Expression Parser { .spec }

Build a utility that converts standard cron expressions into human-readable descriptions. The utility should support 5-part cron expressions following the standard format: minute, hour, day-of-month, month, and day-of-week.

Requirements { .requirements }

Your solution must:

  1. Accept a 5-part cron expression string as input
  2. Return a human-readable English description of when the cron job will execute
  3. Support all standard cron operators:
    • Asterisk (*) for "all values"
    • Comma (,) for multiple specific values
    • Hyphen (-) for ranges
    • Slash (/) for step/increment values
  4. Handle named days and months (e.g., MON, TUE, JAN, FEB) in a case-insensitive manner
  5. Provide appropriate error handling for invalid expressions

Input Format { .input-format }

  • A string representing a 5-part cron expression
  • Parts are separated by spaces
  • Format: minute hour day-of-month month day-of-week

Output Format { .output-format }

  • A string containing a human-readable description of the cron schedule

Examples { .examples }

Example 1: Every 5 minutes

Input: "*/5 * * * *"

Output: Should describe running every 5 minutes

Example 2: Specific time daily

Input: "30 14 * * *"

Output: Should describe running at 2:30 PM every day

Example 3: Weekday range

Input: "0 9 * * MON-FRI"

Output: Should describe running at 9:00 AM on Monday through Friday

Example 4: Multiple specific times

Input: "0 6,12,18 * * *"

Output: Should describe running at 6:00 AM, 12:00 PM, and 6:00 PM

Test Cases { .test-cases }

Test 1: Basic every minute @test

// src/cronParser.test.js
describe('Cron Parser', () => {
  it('should parse every minute expression', () => {
    const result = parseCronExpression('* * * * *');
    expect(result).toContain('minute');
  });
});

Test 2: Specific hour and minute @test

// src/cronParser.test.js
describe('Cron Parser', () => {
  it('should parse specific time expression', () => {
    const result = parseCronExpression('30 11 * * *');
    expect(result).toContain('11:30');
  });
});

Test 3: Day of week with range @test

// src/cronParser.test.js
describe('Cron Parser', () => {
  it('should parse weekday range expression', () => {
    const result = parseCronExpression('0 23 * * MON-FRI');
    expect(result).toContain('Monday');
    expect(result).toContain('Friday');
  });
});

Test 4: Step values @test

// src/cronParser.test.js
describe('Cron Parser', () => {
  it('should parse step value expression', () => {
    const result = parseCronExpression('*/15 * * * *');
    expect(result).toContain('15');
  });
});

Implementation Notes { .implementation-notes }

  • Focus on clarity and correctness of the human-readable output
  • The solution should be maintainable and testable
  • Consider edge cases like boundary values and invalid inputs

Dependencies { .dependencies }

cronstrue { .dependency }

A library that provides cron expression parsing and conversion capabilities.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/cronstrue@3.2.x
tile.json