Skip to main content

This is an astral wrapper, that adds functionality for getting the part of day for a spesific datetime.

Project description

Part of Day

This is an astral package wrapper, that uses it's calculations to give the part of day, instead of giving time intervals for spesific parts.

Installation

To install, run the following command

pip install part-of-day

Usage

from part_of_day import PartOfDayCalculator

from datetime import datetime, timezone

pod = PartOfDayCalculator(latitude=15.33, longitude=-7)

# following methods gives results related to now, if a datetime is not given
pod.is_it_day()
# True
pod.is_it_night()
# False
pod.get_part_of_day()
# <PartOfDay.DAY: 'Day'>

# or they can be used with a datetime
dt = datetime(2025, 3, 12, 6, 13, 25, 0, timezone.utc)

pod.is_it_day(dt)
# False
pod.is_it_night(dt)
# True
pod.get_part_of_day(dt)
# <PartOfDay.NIGHT: 'Night'>

Including twilights

By setting include_twilights flag in calculator's init, you can enable calculations for dusk and dawn (normally, both counts as night). This also enables using is_it_dawn and is_it_dusk methods.

from part_of_day import PartOfDayCalculator, PartOfDay

from datetime import datetime, timezone

pod = PartOfDayCalculator(latitude=15.33, longitude=-7, include_twilights=True)

# following methods gives results related to now, if a datetime is not given
pod.is_it_day()
# True
pod.is_it_night()
# False
pod.is_it_dawn()
# False
pod.is_it_dusk()
# False
pod.get_part_of_day()
# <PartOfDayWithTwilights.DAY: 'Day'>

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

part_of_day-0.5.0.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

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

part_of_day-0.5.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file part_of_day-0.5.0.tar.gz.

File metadata

  • Download URL: part_of_day-0.5.0.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.10.12 Linux/6.14.0-33-generic

File hashes

Hashes for part_of_day-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d78ef6b0a1c772089ba006588194dc41d6ae1931bbd6ecf28d603e8dd61fc1b4
MD5 591215ea4d99f1f857410093012627e3
BLAKE2b-256 37acefb021e8f81eaceeda9f85f1d1c26aa08c15d0ccf95baa1fcb7be2c07196

See more details on using hashes here.

File details

Details for the file part_of_day-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: part_of_day-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.0 CPython/3.10.12 Linux/6.14.0-33-generic

File hashes

Hashes for part_of_day-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66bb1e70320c2837b17e6e16c520c7e9a3627f69ec3ad9bfd1f4e70258d3d91f
MD5 ac55042cb28897c0594bc671fb4e7bce
BLAKE2b-256 28994aff895331bbb0968f92699f4a51ffde12a4d9c76ed120bb2bffbd62d159

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