Skip to content

Commit 74ce819

Browse files
committed
readme fixed.
1 parent 1d773af commit 74ce819

File tree

1 file changed

+53
-15
lines changed

1 file changed

+53
-15
lines changed

README.rst

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
crontools
33
=========
44

5+
.. image:: https://github.com/dapper91/crontools/actions/workflows/test.yml/badge.svg
6+
:target: https://github.com/dapper91/crontools/actions/workflows/test.yml
7+
:alt: Build status
8+
.. image:: https://img.shields.io/pypi/l/crontools.svg
9+
:target: https://pypi.org/project/crontools
10+
:alt: License
11+
.. image:: https://img.shields.io/pypi/pyversions/crontools.svg
12+
:target: https://pypi.org/project/crontools
13+
:alt: Supported Python versions
14+
.. image:: https://codecov.io/gh/dapper91/crontools/branch/master/graph/badge.svg
15+
:target: https://codecov.io/gh/dapper91/crontools
16+
:alt: Code coverage
17+
18+
19+
``crontools`` is a library that allows you to parse crontab expression and iterate over scheduled fire times.
20+
21+
522
Features:
623

724
- crontab expression parser
@@ -22,28 +39,49 @@ You can install crontools with pip:
2239
Quickstart
2340
----------
2441

25-
On the server side everything is also pretty straightforward:
42+
43+
Get next cron fire time:
44+
________________________
2645

2746
.. code-block:: python
2847
29-
import datetime as dt
30-
import crontools as ct
48+
>>> import datetime as dt
49+
>>> import crontools as ct
50+
>>>
51+
>>> tz = dt.timezone.utc
52+
>>> now = dt.datetime.fromisoformat('2020-02-29 23:59:59.999+00:00')
53+
>>> ct = ct.Crontab.parse(
54+
... '* * * * * * *',
55+
... seconds_ext=True,
56+
... years_ext=True,
57+
... tz=tz,
58+
... )
59+
>>>
60+
>>> print(f"Next fire time: {ct.next_fire_time(now=now)}")
61+
Next fire time: 2020-03-01 00:00:00+00:00
3162
32-
tz = dt.timezone.utc
33-
now = dt.datetime.fromisoformat('2021-02-01 00:00:00+00:00')
34-
ct = ct.Crontab.parse(
35-
'30 30 12-16/2 1,2 JAN SAT,SUN *',
36-
seconds_ext=True,
37-
years_ext=True,
38-
tz=tz,
39-
)
4063
41-
cron_iter = ct.iter(start_from=now)
42-
for n, fire_datetime in zip(range(1, 31), cron_iter):
43-
print("{n:2}: {dt}".format(n=n, dt=fire_datetime))
64+
Iteration over cron fire times starting from now:
65+
_________________________________________________
4466

45-
output:
67+
.. code-block:: python
4668
69+
>>> import crontools as ct
70+
>>>
71+
>>> tz = dt.timezone.utc
72+
>>> now = dt.datetime.fromisoformat('2021-02-01 00:00:00+00:00')
73+
>>> ct = ct.Crontab.parse(
74+
... '30 30 12-16/2 1,2 JAN SAT,SUN *',
75+
... seconds_ext=True,
76+
... years_ext=True,
77+
... tz=tz,
78+
... )
79+
>>>
80+
>>> cron_iter = ct.iter(start_from=now)
81+
>>> for n, fire_datetime in zip(range(1, 31), cron_iter):
82+
... print("{n:2}: {dt}".format(n=n, dt=fire_datetime))
83+
...
84+
...
4785
1: 2022-01-01 12:30:30+00:00
4886
2: 2022-01-01 14:30:30+00:00
4987
3: 2022-01-01 16:30:30+00:00

0 commit comments

Comments
 (0)