WeeklyCalendar
A simple library to deal with weekly opening hours and other recurrent weekly events
Usage
Methods will either return a Boolean or datetime based intervals.
from weekly_calendar import WeeklyCalendar
from datetime import datetime, timedelta
now = datetime.now()
typical_week = WeeklyCalendar(resolution_in_minutes=60)
# typical_week is mapped into a bitmap with a bit representing one hour
assert typical_week.is_idle(now)
typical_week.add_busy_interval(now, now + timedelta(hours=3))
# the date doens't really matter, only the day of the week does
assert typical_week.is_busy(now)
busy_intervals = typical_week.get_busy_intervals(now, now + timedelta(hours=5))
# The result is a list of intervals (start_time, end_time)
idle_intervals = typical_week.get_idle_intervals(now, now + timedelta(hours=5))
# The result is a list of intervals (start_time, end_time)
You can also do union and intersection of different WeeklyCalendar objects:
from weekly_calendar import WeeklyCalendar
tw_60 = WeeklyCalendar(resolution_in_minutes=60)
tw_30 = WeeklyCalendar(resolution_in_minutes=30)
# resulting objects will have the lowest resolution
tw_union = tw_30 + tw_60
tw_intersection = tw_30 * tw_60
You can change resolution of an existing WeeklyCalendar object:
from weekly_calendar import WeeklyCalendar
tw_60 = WeeklyCalendar(resolution_in_minutes=60)
tw_60_to_30 = tw_60.copy(resolution_in_minutes=30)
Your WeeklyCalendar object is serializable:
from weekly_calendar import WeeklyCalendar
tw = WeeklyCalendar()
str_repr = tw.dumps()
tw_loaded = WeeklyCalendar.loads(str_repr)
# checks equal resolution, bitmap, and extra parameters
assert tw == tw_loaded
Metadata
Release files for weekly-calendar 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| weekly-calendar-0.1.2.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| weekly_calendar-0.1.2-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 8.8 kB
Release files / weekly-calendar-0.1.2.tar.gz
| Download URL | weekly-calendar-0.1.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
828c0d5b73b467550cb36e357af61ca05d6c53315c290a7f4253b29a40918e9f
|
|
BLAKE2b-256 checksum How to use checksums |
edb757ccf71984e1045c9bc80d2a49b1fa4c9b3f34b706ebdc8cca09a9547408
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|
Release files / weekly_calendar-0.1.2-py2-none-any.whl
| Download URL | weekly_calendar-0.1.2-py2-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
1c55c99949b2af5559c5cd0573635182977efef89fa6fd479b979adcd914304e
|
|
BLAKE2b-256 checksum How to use checksums |
5a29cb5484f45ac2a65e410abc6fba920853fc37d3a52cc843ed8d5efe6d9cc0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/2.7.15
|