Skip to main content
Info:

This is the README file for Date Conditionals.

Author:

Chris Warrick <chris@chriswarrick.com>

Date:
2020-07-01
Version:
0.1.7
https://travis-ci.org/Kwpolska/datecond.svg?branch=master

PURPOSE

This is a minimalistic (and slightly hacky) parser for date range conditionals.

INSTALLATION

pip install datecond

FORMAT

  • comma-separated clauses (AND)

  • clause: attribute comparison_operator value (spaces optional)
    • attribute: year, month, day, hour, month, second, weekday, isoweekday or empty for full datetime

    • comparison_operator: == != <= >= < >

    • value: integer, ‘now’, ‘today’, or dateutil-compatible date input

API

The library exposes only one function:

date_in_range(date_range, date, debug=True, now=None)

Where date_range is the date conditional (see FORMAT above), date is a datetime object, and now is the current date (used for ‘now’/’today’ comparisons; if not specified, datetime.datetime.now() or datetime.date.today() is used)

CLI USAGE

$ python -m datecond
Date range to accept: year == 2016
Date to test: 2016-01-01
    Date parsed: 2016-01-01 00:00:00
    <2016 == 2016>
    In range: True
Date to test: 2016-02-02
    Date parsed: 2016-02-02 00:00:00
    <2016 == 2016>
    In range: True
Date to test: 2017-01-01
    Date parsed: 2017-01-01 00:00:00
    <2017 == 2016>
    In range: False

$ python -m datecond
Date range to accept: year == 2016, month > 06, day >= 07
Date to test: 2016-06-07
    Date parsed: 2016-06-07 00:00:00
    <2016 == 2016>
    <6 > 6>
    <7 >= 7>
    In range: False
Date to test: 2016-07-07
    Date parsed: 2016-07-07 00:00:00
    <2016 == 2016>
    <7 > 6>
    <7 >= 7>
    In range: True
Date to test: 2016-08-08
    Date parsed: 2016-08-08 00:00:00
    <2016 == 2016>
    <8 > 6>
    <8 >= 7>
    In range: True
Date to test: 2015-07-07
    Date parsed: 2015-07-07 00:00:00
    <2015 == 2016>
    <7 > 6>
    <7 >= 7>
    In range: False

Metadata

Release files for datecond 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datecond 0.1.7
File Size Uploaded
datecond-0.1.7.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datecond 0.1.7
File Interpreter ABI Platform
datecond-0.1.7-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.6 kB

Release files / datecond-0.1.7.tar.gz

Download URL datecond-0.1.7.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
08b36680c8d3838a18a04bfd866906b96c265e4cd851302535248737070dac9d
BLAKE2b-256 checksum
How to use checksums
563e63b3646b5265075964c502e7115303837d90659bf56afc2a3a64223f3478
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

Release files / datecond-0.1.7-py2.py3-none-any.whl

Download URL datecond-0.1.7-py2.py3-none-any.whl
Size 8.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f0bd2e30e7b3212a81165be14e4f0e24d6535cdd0fbb2982f1b8865cf4804c73
BLAKE2b-256 checksum
How to use checksums
84b74d47c54ab8c5d2d2cea20b482bbb81ddf942af5c0118b858b0640f17272a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page