Utility for int date like 20150312.
Project description
Integer Date utilities
VERSION: 0.2.0
This module contains the utilities for operating integer date, such as: 20150301
Issues
We use Github Issues to manage the issues.
Contact author:
LICENSE
API Document
###int_date
Converts the input to an integer that represents a date.
- Parameter: a
str,datetime.datetime,datetime.dateor number - Exception:
ValueErrorif the input could not be converted - Return: an integer represents a date
Examples:
>>> int_date(10121015.0)
10121015
>>> int_date('2012/10/15')
10121015
>>> int_date('2012-10-15')
10121015
>>> int_date(datetime.date(2015, 5, 21))
20150521
to_date
Converts the input to datetime.date
- Parameter: a
stror number - Exception:
ValueErrorif the input could not be converted - Return: a
datetime.dateobject
Examples:
>>> to_date(20151205)
datetime.date(2015, 12, 5)
>>> to_date('2015-12-05')
datetime.date(2015, 12, 5)
get_interval
Retrieve the days between two dates.
- Parameter: 2 inputs that represents valid dates
- Exception:
ValueErrorif any of the input is not valid - Return: the days in between
Examples:
>>> get_interval(20120530, '2012-06-02')
3
>>> get_interval('2012/6/6', '2012-06-02')
-4
from_diff
Retrieve the int date from a start date and a delta.
- Parameter: a start date and a delta
- Exception:
ValueErrorif start date is not valid - Return: the result date
Examples:
>>> from_diff('2012-7-31', 5)
20120805
>>> from_diff('2012/8/3', -10)
20120724
in_month, in_date & in_year
Check whether the int date matches the specified month, date or year.
- Parameter: an int date and multiple value to match
- Exception:
ValueErrorif the int date is not valid - Return: true if it matches, false if not
Examples:
>>> in_date(20140503, *[3, 5, 7])
True
>>> in_month('2014-05-03', *{3, 5, 7})
True
>>> in_month(20140131, *[3, 5, 7])
False
>>> in_date('2014-01-31', 30)
False
today
Retrieve the int date that represents today.
get_workdays
Retrieve the work days (Monday~Friday) between two dates
- Parameter: two int dates mark the start and end, both ends are inclusive
- Exception:
ValueErrorif the input date is not valid - Return: number of workdays
Example:
# Note: 2022-01-03 is Monday
>>> get_workdays(20220102, 20220108)
5
>>> get_workdays(20220102, 20220107)
5
>>> get_workdays(20220102, 20220106)
4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file int_date-0.2.0.tar.gz.
File metadata
- Download URL: int_date-0.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6539a9629b5d97b0fbc95bb9403683c074556e55c8d6dc143f6e20bb236ee61c
|
|
| MD5 |
0c0e787bdc893ed603e1cc9d243afd2b
|
|
| BLAKE2b-256 |
159e146b4ea9d7892b7b21948269f37e8e79724c1da2a059d282c2367a3ea072
|
File details
Details for the file int_date-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: int_date-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a26379b86d7b0c91f8908e03bec4b19ad5067030418fca2a5f2b3a1ca33e135
|
|
| MD5 |
3b1689bc344e3dfd225d12e67f95b40f
|
|
| BLAKE2b-256 |
41d23ad7aefffa8ccd653a11d5f0a3de59a5602177c8e45346f531ef9f0bb62c
|