Skip to main content

No project description provided

Project description

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

PyPI - Version PyPI - Python Version


Table of Contents

Installation

pip install django-time-block

License

django-time-block is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_time_block-0.1.1.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_time_block-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file django_time_block-0.1.1.tar.gz.

File metadata

  • Download URL: django_time_block-0.1.1.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.0

File hashes

Hashes for django_time_block-0.1.1.tar.gz
Algorithm Hash digest
SHA256 24509f30c5a3bec428b44f25eaf348530661827ebbd533f4272297650bd660a5
MD5 55f2739a9dfd2b325a80bd5c24a15d94
BLAKE2b-256 805e26f2e6b2ae9d72e34cfef69972a4f353e2c702a1b8e4c1317cb78274750c

See more details on using hashes here.

File details

Details for the file django_time_block-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_time_block-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e21bc6774c4e7e9bda6a12dfa0fba7966847c01d2d66e2638d051965b947c4ae
MD5 b1153b2d4a49f1c9604f08dbcbd1f89e
BLAKE2b-256 2479a328ac55a785f5cfaaace63dc89e6db3e7041c9c5765e3dca3d62fe6811c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page