django-time-block
an django application to save the timeline information of an object.
Tutorial
from django_time_block.utils import add_time_block
def format_datetime(date_str: str) -> datetime.datetime:
"""formate datetime string format"""
return datetime.datetime.strptime(
date_str,
"%Y-%m-%d %H:%M:%S",
).astimezone(
timezone.get_current_timezone(),
)
# record alice's work time according to her clock in record
object_id = "work_time_user_alice"
add_time_block( # a timeblock record will be created
object_id=object_id,
start_datetime=format_datetime("2023-09-01 00:00:00"),
end_datetime=format_datetime("2023-09-05 00:00:00"),
)
all_include( # alice didn't work from 2023-09-05 00:00 to 2023-09-06 00:00
object_id,
format_datetime("2023-09-02 00:00:00"),
format_datetime("2023-09-06 00:00:00"),
) # False
TimeBlock.objects.filter(object_id=object_id).count() # 1
add_time_block( # the second record will merged int the first one
object_id=object_id,
start_datetime=format_datetime("2023-09-01 00:00:00"),
end_datetime=format_datetime("2023-09-05 00:00:00"),
)
TimeBlock.objects.filter(object_id=object_id).count() # 1
all_include(
object_id,
format_datetime("2023-09-02 00:00:00"),
format_datetime("2023-09-06 00:00:00"),
) # True
-
For example: You have to handle a lot of data from 2000-01-01 to 2023-11-11.
-
First day, you may handle the data from 2023-10-01 to 2023-11-11
-
Next day, you may have handled the data from 2023-09-01 to 2023-09-07: the results look like this:
you will record:
2023-09-01~2023-09-07, 2023-10-01~2023-11-11- the third day, you handled the data from 2023-09-06 to 2023-10-02 then, the records will merge into one:
this two records will be merged:
2023-09-01 ~ 2023-11-11 -
API
-
add_time_block
-
all_include
check if a duration is all included -
find_min_uninclude
find the earliest datetime that was not included -
find_max_uninclude
find the latest datetime that was not included -
find_uninclude_blocks
find all the uninclude durations
Table of Contents
Installation
pip install django-time-block
License
django-time-block is distributed under the terms of the MIT license.
Metadata
Release files for django-time-block 0.5.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 | Provenance | Actions |
|---|---|---|---|---|
| django_time_block-0.5.0.tar.gz | 7.3 kB | Without provenance | Details for django_time_block-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_time_block-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for django_time_block-0.5.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / django_time_block-0.5.0.tar.gz
| Download URL | django_time_block-0.5.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41c3c99aa14fbc994f911252d9fca9c52b95f381a69081183cb0bbe6a45ddf04
|
|
BLAKE2b-256 checksum How to use checksums |
42f7334c45690edd376a9e841702371dd4296d2ee3ed5c9a8b46d2c6d335da64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.0
|
Release files / django_time_block-0.5.0-py3-none-any.whl
| Download URL | django_time_block-0.5.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca5d5a47e07c56f086deffb65e47307e4a316c58219b5675a7d1a92a359fc55c
|
|
BLAKE2b-256 checksum How to use checksums |
af530b3f1812dacafe4af5d5c8ad22aaa6b2ff63fc2402f97fcd998f593265ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-httpx/0.25.0
|
Security for django-time-block 0.5.0
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.