DateString
Creates a manipulable date string in the form of 'YYYYmmdd'.
Usage
- creates date string from various inputs.
>>> ds = DateString('20180624')
>>> ds
'20180624'
>>> ds = DateString('2018/06/24')
>>> ds
'20180624'
>>> ds = DateString('2018-06-24')
>>> ds
'20180624'
>>> ds = DateString('2018年6月24日')
>>> ds
'20180624'
>>> ds = DateString(datetime.datetime(2018, 6, 24))
>>> ds
'20180624'
>>> today = DateString.today()
>>> yesterday = DateString.today(-1)
>>> tomorrow = DateString.today(1)
- supports date calculation.
>>> DateString('2018/6/24') + 90
'20180922'
>>> DateString('2018-09-22') - 90
'20180624'
>>> DateString('2018-09-22') - '2018/06/24'
90
>>> DateString('2018/9/22') - datetime.datetime(2018, 6, 24)
90
>>> DateString('20180922') - DateString('2018-6-24')
90
>>> DateString('2018年9月22日') - pd.Timestamp('2018-06-24')
90
- supports date comparison.
>>> DateString('20180922') == '2018/9/22'
True
>>> DateString('20180922') == '2018/6/24'
False
>>> DateString('20180922') >= '2018/6/24'
True
>>> DateString('20180922') >= '2019/9/22'
False
- supports date-related properties.
>>> ds = DateString('2018-06-24')
>>> ds.year
2018
>>> ds.month
6
>>> ds.day
24
>>> ds.dayofweek
6
>>> ds.dayofyear
175
>>> ds.is_leap_year
False
>>> ds.is_weekday
False
>>> ds.is_weekend
True
- compatible with
pandas.date_range().
>>> begin_ds = DateString('2019-01-01')
>>> end_ds = DateString('2019/1/3')
>>> pd.date_range(begin_ds, end_ds)
DatetimeIndex(['2019-01-01', '2019-01-02', '2019-01-03'], dtype='datetime64[ns]', freq='D')
- supports date string reformatting.
>>> ds = DateString('20180624')
>>> ds.reformat()
'2018-06-24'
>>> ds.reformat(delimiter='/')
'2016/06/24'
Metadata
Release files for date-string 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| date_string-0.2.1.tar.gz | 3.1 kB | Without provenance | Details |
Release files / date_string-0.2.1.tar.gz
| Download URL | date_string-0.2.1.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
644a5603fea7eaba80549480cdb198bc9b2dbf395bbfd1c259b6f83c36a8ebc8
|
|
BLAKE2b-256 checksum How to use checksums |
c6a3e49d07c7bed317178cbcb3f7f9324fd35472449f5322fae3cd4256b902e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for date-string 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.