Split time range into ~N "rounded" intervals using the following logic:
Divide range by N and select the closest step from below:
- One year
- Six months, three months, one month
- Two weeks, one week
- One day
- Hours: 12, 6, 4, 3, 2, 1
- Minutes: 30, 20, 15, 10, 5, 1
- Seconds: 30, 20, 15, 10, 5, 1
If the interval is greater than one year, then use Pretty Breaks algorithm for the step.
Each interval starts with time multiple of step. E.g., if we have 20 min step
and the range starts at 19:43, then the first interval should starts at 19:40.
## Examples
| Range start | Range end | N | Result | Description |
|---------------------|------------------|----|---------------------------------------------------------------------------------------------------------------|-----------------------------------------|
| 2019-04-04 | 2019-05-19 | 7 | 2019-04-01, 2019-04-08, 2019-04-15, 2019-04-22, 2019-04-29, 2019-05-06, 2019-05-13, 2019-05-20 | Split by one week, starts on Monday |
| 2019-03-31 02:59:02 | 2019-03-31 03:02 | 50 | 2019-03-31 02:59:00, 2019-03-31 02:59:05, 2019-03-31 02:59:10, ... , 2019-03-31 03:01:55, 2019-03-31 03:02:00 | Split by 5 sec, starts at multiple time |
| 2018-12-31 | 2019-12-19 | 5 | 2018-10-01, 2019-01-01, 2019-04-01, 2019-07-01, 2019-10-01, 2020-01-01 | Split by three months, starts at Jan. 1 |
## Usage
```python
>>> from time_pretty_breaks import nice_dt_intervals
>>> from datetime import datetime
>>> nice_dt_intervals(datetime(2018, 12, 31), datetime(2019, 12, 19), 5)
[datetime.datetime(2018, 10, 1, 0, 0), datetime.datetime(2019, 1, 1, 0, 0), datetime.datetime(2019, 4, 1, 0, 0), datetime.datetime(2019, 7, 1, 0, 0), datetime.datetime(2019,
10, 1, 0, 0), datetime.datetime(2020, 1, 1, 0, 0)]
```
Metadata
Release files for time-pretty-breaks 0.1.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 | Actions |
|---|---|---|---|---|
| time-pretty-breaks-0.1.1.tar.gz | 3.0 kB | Without provenance | Details for time-pretty-breaks-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| time_pretty_breaks-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for time_pretty_breaks-0.1.1-py3-none-any.whl |
Total release size: 7.1 kB
Release files / time-pretty-breaks-0.1.1.tar.gz
| Download URL | time-pretty-breaks-0.1.1.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3b3eff13e307acf74d873e7356f43ff8abe11f33278e6b68df0f376d23a346b
|
|
BLAKE2b-256 checksum How to use checksums |
97c41c49bc61330fa29c0c1862140e2b97a0101a8824e10de5da5deb77d3009f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / time_pretty_breaks-0.1.1-py3-none-any.whl
| Download URL | time_pretty_breaks-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13a023d679ef6dd92882fa4a817a7be4221b775a1feebfb22c8960d47ba9f4d1
|
|
BLAKE2b-256 checksum How to use checksums |
6785321dc89fe370abbd723c6d5dd8c2920bf415d98e332c3663c26d26f0b333
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for time-pretty-breaks 0.1.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.