{"id":8292,"library":"local-crontab","title":"local-crontab","description":"local-crontab is a Python wheel and command line utility designed to convert a crontab, defined in a local timezone, into a set of UTC crontabs. This conversion often results in multiple UTC crontabs due to the complexities of Daylight Saving Time (DST). The project is based on an earlier `local-crontab` by UnitedIncome, incorporating bug fixes and extending functionality to convert specific hour and day parts. As of version 0.3.0, released in July 2021, the library appears to be in a maintenance status with infrequent updates.","status":"maintenance","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/Sonic0/local-crontab","tags":["cron","timezone","dst","scheduling","utility"],"install":[{"cmd":"pip install local-crontab","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for parsing and manipulating cron strings.","package":"python-crontab","optional":false},{"reason":"Required for timezone calculations, especially for handling Daylight Saving Time.","package":"pytz","optional":false},{"reason":"Used for determining the local timezone.","package":"tzlocal","optional":false}],"imports":[{"symbol":"Converter","correct":"from local_crontab import Converter"}],"quickstart":{"code":"from local_crontab import Converter\n\n# Example 1: Convert a crontab from 'America/New_York' to UTC\n# This will typically produce two UTC crontabs due to DST changes.\nconverter_ny = Converter('0 10 * * *', 'America/New_York')\nutc_crontabs_ny = converter_ny.convert()\nprint(f\"Original (NY): 0 10 * * *\")\nprint(f\"UTC conversions for 'America/New_York': {utc_crontabs_ny}\")\n# Expected output similar to: ['0 15 * * *', '0 14 * * *'] (order may vary)\n\n# Example 2: Convert a crontab for 'Europe/Berlin'\n# Also likely to produce two UTC crontabs due to DST.\nconverter_berlin = Converter('30 8 * * *', 'Europe/Berlin')\nutc_crontabs_berlin = converter_berlin.convert()\nprint(f\"\\nOriginal (Berlin): 30 8 * * *\")\nprint(f\"UTC conversions for 'Europe/Berlin': {utc_crontabs_berlin}\")\n# Expected output similar to: ['30 7 * * *', '30 6 * * *'] (order may vary)","lang":"python","description":"Demonstrates how to instantiate the `Converter` class with a local crontab string and its timezone, then use the `convert()` method to get a list of corresponding UTC crontab strings."},"warnings":[{"fix":"Understand that the output of `converter.convert()` is a list of crontab strings. Implement logic to select the appropriate UTC crontab based on the current date, or consider external 'dst check' mechanisms if only one active UTC schedule is required year-round.","message":"The library typically generates multiple UTC crontab entries for a single local crontab. This is by design, accounting for Daylight Saving Time (DST) changes throughout the year. Users expecting a single, fixed UTC equivalent might find this behavior unexpected.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that the 'single UTC crontab' feature for hour/day parts is a partial solution. If full DST awareness and year-round accuracy are critical, an external mechanism to manage the active UTC schedule is necessary.","message":"While the library allows converting crontab 'hour and day parts' to a single UTC equivalent, maintaining year-round accuracy through DST changes requires an *external* 'dst check' program. This external tool is not part of the `local-crontab` library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If migrating from an older 'UnitedIncome' version, review the GitHub repository's commit history and source code for any unlisted changes. Thorough testing of existing workflows is recommended.","message":"This `local-crontab` package is a fork and bug-fixed version of an older project by 'UnitedIncome'. While improvements are included, users familiar with or migrating from the original might encounter subtle behavioral differences or API changes not explicitly documented as breaking changes.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed via `pip install local-crontab`. The correct import statement is `from local_crontab import Converter` (note the underscore in `local_crontab`).","cause":"The `local-crontab` package was installed, but the import statement uses an incorrect module name or the package is not in Python's `sys.path`.","error":"ModuleNotFoundError: No module named 'local_crontab'"},{"fix":"The `Converter` class expects exactly two arguments: the crontab string and the local timezone string, e.g., `Converter('0 10 * * *', 'America/New_York')`.","cause":"The `Converter` class constructor was called with an incorrect number of arguments.","error":"TypeError: Converter() takes 2 positional arguments but 3 were given"},{"fix":"Ensure the timezone string passed to `Converter` is a valid `pytz` timezone name (e.g., 'America/New_York', 'Europe/London'). Consult the `pytz` documentation for a list of supported timezones.","cause":"An invalid or unrecognized timezone string was provided to the `Converter` class.","error":"pytz.exceptions.UnknownTimeZoneError: 'Invalid/Unknown' is not a valid timezone"}]}