Skip to main content

Convenience functions to work with dates

Project description

License

Date Magic

datemagic module provides convenience function for operating with dates and time types.

Install the module the usual way using pip to start using it.

Example

Splitting year in 30-day chunks

>>> import datetime
>>> import datemagic
>>> datemagic.split_interval(datetime.date(2016,1,1),
...                          datetime.date(2016,12,31))
[(datetime.date(2016, 1, 1), datetime.date(2016, 1, 30)),
 (datetime.date(2016, 1, 31), datetime.date(2016, 2, 29)),
 (datetime.date(2016, 3, 1), datetime.date(2016, 3, 30)),
 (datetime.date(2016, 3, 31), datetime.date(2016, 4, 29)),
 (datetime.date(2016, 4, 30), datetime.date(2016, 5, 29)),
 (datetime.date(2016, 5, 30), datetime.date(2016, 6, 28)),
 (datetime.date(2016, 6, 29), datetime.date(2016, 7, 28)),
 (datetime.date(2016, 7, 29), datetime.date(2016, 8, 27)),
 (datetime.date(2016, 8, 28), datetime.date(2016, 9, 26)),
 (datetime.date(2016, 9, 27), datetime.date(2016, 10, 26)),
 (datetime.date(2016, 10, 27), datetime.date(2016, 11, 25)),
 (datetime.date(2016, 11, 26), datetime.date(2016, 12, 25)),
 (datetime.date(2016, 12, 26), datetime.date(2016, 12, 31))]

Default chunk size is 30 days.

For detailed description see the Python docstrings in the code.

Project details


Release history Release notifications

This version
History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
datemagic-0.1.tar.gz (447.3 kB) Copy SHA256 hash SHA256 Source None Feb 7, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page