{"id":1433,"library":"cronsim","title":"Cron Expression Parser and Evaluator","description":"cronsim is a Python library (current version 2.7) for parsing cron expressions and simulating their execution. It allows calculating the next scheduled run time based on a given start date. It receives low but steady maintenance, with updates for bug fixes and minor features.","status":"active","version":"2.7","language":"en","source_language":"en","source_url":"https://github.com/cuu508/cronsim.git","tags":["cron","scheduler","time","datetime","parser"],"install":[{"cmd":"pip install cronsim","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"CronSim","correct":"from cronsim import CronSim"}],"quickstart":{"code":"from datetime import datetime\nfrom cronsim import CronSim\n\n# Daily at midnight\ncron_expression = \"0 0 * * *\"\nsim = CronSim(cron_expression)\n\n# Get the next run after a specific date\nstart_date = datetime(2023, 1, 1, 10, 30, 0)\nnext_run = sim.next(start_date)\nprint(f\"Cron expression: '{cron_expression}'\")\nprint(f\"Next run after {start_date}: {next_run}\")\n\n# Example with a more frequent schedule (every 15 minutes)\ncron_expression_2 = \"*/15 * * * *\"\nsim_2 = CronSim(cron_expression_2)\nstart_date_2 = datetime(2024, 7, 15, 14, 0, 0)\nnext_run_2 = sim_2.next(start_date_2)\nprint(f\"\\nCron expression: '{cron_expression_2}'\")\nprint(f\"Next run after {start_date_2}: {next_run_2}\")","lang":"python","description":"Initialize CronSim with a cron expression and use the `.next()` method to find the next scheduled run after a given datetime object."},"warnings":[{"fix":"Review the `CHANGELOG.md` and `README.md` for specific migration steps. Essentially, it's a new library requiring a full re-implementation of cron logic.","message":"Version 2.0.0 introduced a complete rewrite of the library in Python, moving away from its previous JavaScript-based implementation (node-cron). This means the API is entirely different for users migrating from versions prior to 2.0.0.","severity":"breaking","affected_versions":"< 2.0.0"},{"fix":"Ensure your project's Python environment is 3.10 or newer. Upgrade your Python interpreter if necessary.","message":"cronsim requires Python 3.10 or newer. Attempting to install or run it on older Python versions will result in dependency resolution errors or runtime failures.","severity":"gotcha","affected_versions":"All versions >= 2.0"},{"fix":"If you need to include `start_date` as a potential run time, you might need to check `start_date` against the cron expression separately or adjust `start_date` slightly backwards (e.g., by 1 microsecond) before calling `next()`.","message":"The `next()` method calculates the *next* occurrence strictly *after* the `start_date` parameter. If `start_date` itself happens to be a valid cron execution time, it will not be returned; instead, the subsequent run time will be given.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}