local-crontab

0.3.0 · maintenance · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

from local_crontab import Converter

# Example 1: Convert a crontab from 'America/New_York' to UTC
# This will typically produce two UTC crontabs due to DST changes.
converter_ny = Converter('0 10 * * *', 'America/New_York')
utc_crontabs_ny = converter_ny.convert()
print(f"Original (NY): 0 10 * * *")
print(f"UTC conversions for 'America/New_York': {utc_crontabs_ny}")
# Expected output similar to: ['0 15 * * *', '0 14 * * *'] (order may vary)

# Example 2: Convert a crontab for 'Europe/Berlin'
# Also likely to produce two UTC crontabs due to DST.
converter_berlin = Converter('30 8 * * *', 'Europe/Berlin')
utc_crontabs_berlin = converter_berlin.convert()
print(f"\nOriginal (Berlin): 30 8 * * *")
print(f"UTC conversions for 'Europe/Berlin': {utc_crontabs_berlin}")
# Expected output similar to: ['30 7 * * *', '30 6 * * *'] (order may vary)

view raw JSON →