Git Product home page Git Product logo

crontabula's Introduction

Hello! ๐Ÿ‘‹

  • ๐Ÿ˜Ž I'm Tom
  • ๐Ÿ  I live in London
  • ๐Ÿ I like Python
  • ๐Ÿฆ€ And rust
  • ๐ŸŒ check out my blog

crontabula's People

Contributors

dependabot[bot] avatar orf avatar razerm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crontabula's Issues

Day of month is not taken into account

โฏ crontabula '0 0 1 * *'
minute         0
hour           0
day of month   1
month          1 2 3 4 5 6 7 8 9 10 11 12
day of week    0 1 2 3 4 5 6
next time      2022-05-10 00:00:00 (in 8:05:39.521698)

Iteration should stop instead of raising a ValueError if datetime.MAXYEAR is reached

You can reach this state by iterating over all dates, or probably more commonly by using a cron expression which doesn't make sense like 30th February

>>> import crontabula
>>> crontabula.parse('0 0 30 2 *').next
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "redacted/lib/python3.9/site-packages/crontabula/__init__.py", line 43, in next
    return next(self.date_times())
  File "redacted/lib/python3.9/site-packages/crontabula/__init__.py", line 60, in date_times
    for day in self.dates(anchor_date):
  File "redacted/lib/python3.9/site-packages/crontabula/__init__.py", line 115, in dates
    anchor = datetime.date(year=anchor.year + 1, month=1, day=1)
ValueError: year 10000 is out of range

We'd have to decide whether to make the .next return type Optional[datetime.datetime] or raise an error of its own. I think I prefer the latter

Day of week and day of month should be combined with OR

E.g. 0 0 2 10 6 means 2nd October (which is a Sunday in 2022) OR any Saturday in October:

  • 2022-10-01
  • 2022-10-02
  • 2022-10-08
  • 2022-10-15
  • 2022-10-22

Currently, crontabula (assuming #13 and #14 are already applied) will find the first date where both conditions are true, which is 2027-10-02

Minutes between the start of the hour and the current minute are always skipped

import crontabula
from datetime import datetime
from itertools import islice

cron = crontabula.parse('*/5 * * * *')
start = datetime(2022, 5, 16, 11, 30)

for n in islice(cron.date_times(start), 12):
    print(n)
2022-05-16 11:30:00
2022-05-16 11:35:00
2022-05-16 11:40:00
2022-05-16 11:45:00
2022-05-16 11:50:00
2022-05-16 11:55:00
# 12:00-12:25 are missing
2022-05-16 12:30:00
2022-05-16 12:35:00
2022-05-16 12:40:00
2022-05-16 12:45:00
2022-05-16 12:50:00
2022-05-16 12:55:00

0.1.7 not pushed to PyPI

Sorry if you just didn't get to it, but it would be great if the 0.1.7 release could be pushed to PyPI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.