dates generator

    0

    3

    packituz-gttz

    python

    Generates dates between a range of dates.

    import datetime as dt
    from typing import Iterable, Tuple
    
    def next_date_generator(start: dt.datetime, end: dt.datetime, days_after: int = 1) -> Iterable[Tuple[dt.datetime, dt.datetime]]:
        """ Generates dates between start and end dates with the specified step.
    
        :param start: First date.
        :param end: Last date.
        :param days_after: Step between dates. Must be a positive integer.
        :returns: Generator with the next date.
        """
        if days_after <= 0:
            raise ValueError('Value must be positive')
    
        while start <= end:
            yield start
            start = start + dt.timedelta(days_after)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.