Skip to main content

A simple Python Cron Expression lib

Project description

Python Cron Expression

This is a simple library for making cron job expression. User need to pass timestamp or datetime object to create cron job expression.

Installation

pip install PyCronExpression

Example

from datetime import datetime
from py_cron_expression.py_cron import CronJobExpression
cron_job = CronJobExpression()

timestamp = int(datetime.now().timestamp())
res = cron_job.cron_expression(time=timestamp)
print(res)
# Output 
# 10 55 13 2 5 ? 2020

# If you want to remove second from in your cron job expression. 
# Then you need to add cancel='second'
# example
cron_job.cron_expression(time=timestamp, cancel='second')
# Output 
# 55 13 2 5 ? 2020

If you need to convert the cron job expression to other timezone. Please follow the example. By default your will get the cron job expression as your local timezone.

from datetime import datetime
from py_cron_expression.py_cron import CronJobExpression
cron_job = CronJobExpression()

timestamp = int(datetime.now().timestamp())
res = cron_job.cron_expression(time=timestamp, timezone='Asia/Dhaka')
print(res)
# Output 
# 10 55 13 2 5 ? 2020

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyCronExpression-0.0.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

PyCronExpression-0.0.4-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file PyCronExpression-0.0.4.tar.gz.

File metadata

  • Download URL: PyCronExpression-0.0.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for PyCronExpression-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5ee3d3c30983755de8d4e575281ce76fca55bbda5fd045f04de03b7c0e1c618a
MD5 08b79cf1e1f717f979de917d7ca5f8b6
BLAKE2b-256 487eb7d9d5ec950dad55ee459f7ca46d918d1651fb994e9a995ebc0d2196744f

See more details on using hashes here.

File details

Details for the file PyCronExpression-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: PyCronExpression-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for PyCronExpression-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 821717673a81074ad433398472ac0bb9eb45b196a66a218aa80e657b173c74a7
MD5 0ce85c0815a0412587736201826b314c
BLAKE2b-256 d31474fd86e3db5f570f7e6165ce539c7313e616ae16b5f47914756c29ae0d0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page