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 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 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.5.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

PyCronExpression-0.0.5-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyCronExpression-0.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 53d489e3e89e7451c9ba58d32f3b878e1d446950130e9c80599425980a57a038
MD5 2a8887b5b533cd4030637c3a41697129
BLAKE2b-256 943526d8337ef855c33da2976627ca06be7e169eb259e6a90a8887e6f2817efe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyCronExpression-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f6b341cf49370f1c35d37f9ceb18c4e1770aa9d8c426819d974aca0d60338e8c
MD5 29572b2edb24a648e99a11d4f1c38f99
BLAKE2b-256 c35124d273c548c3991d5961a152f2f8ab92ce52a5aae27575a9ba0a3dac747a

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