lino.utils.dates

Defines classes related to date ranges.

This is a tested document. To test it, run:

$ python setup.py test -s tests.UtilsTests.test_dates

(This module's source code is available here.)

Functions

daterange_text(a, b)

weekdays(start_date, end_date)

Return the number of weekdays that fall in the given period.

Classes

DateRangeValue(start_date, end_date)

A named tuple with the following fields:

class lino.utils.dates.DateRangeValue(start_date, end_date)

Bases: tuple

A named tuple with the following fields:

start_date

The start date

end_date

The end date

property end_date

Alias for field number 1

property start_date

Alias for field number 0

lino.utils.dates.weekdays(start_date, end_date)

Return the number of weekdays that fall in the given period. Does not care about holidays.

Usage examples:

>>> from lino.utils import i2d
>>> weekdays(i2d(20151201), i2d(20151231))
23
>>> weekdays(i2d(20160701), i2d(20160717))
11
>>> weekdays(i2d(20160717), i2d(20160717))
0
>>> weekdays(i2d(20160718), i2d(20160717))
0
lino.utils.dates.daterange_text(a, b)