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
Metadata
Release files for int-date 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| int_date-0.2.0.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| int_date-0.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 10.6 kB
Release files / int_date-0.2.0.tar.gz
| Download URL | int_date-0.2.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6539a9629b5d97b0fbc95bb9403683c074556e55c8d6dc143f6e20bb236ee61c
|
|
BLAKE2b-256 checksum How to use checksums |
159e146b4ea9d7892b7b21948269f37e8e79724c1da2a059d282c2367a3ea072
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / int_date-0.2.0-py2.py3-none-any.whl
| Download URL | int_date-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3a26379b86d7b0c91f8908e03bec4b19ad5067030418fca2a5f2b3a1ca33e135
|
|
BLAKE2b-256 checksum How to use checksums |
41d23ad7aefffa8ccd653a11d5f0a3de59a5602177c8e45346f531ef9f0bb62c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|