Skip to main content

Weekdays and datetime properties for the dataclass_property library.

Examples

import time
import datetime
from dataclass_property import dataclass, field, fields
from dataclass_dateproperty import datetime_property, time_property, date_property, Weekdays, weekdays_property

now = datetime.datetime.now()
time.sleep(0.1)

@dataclass
class Alarm:
    timer = datetime_property(default_factory=datetime.datetime.now)
    weekdays: Weekdays = field(default_factory=Weekdays(monday=True).copy)
    sunday: bool = weekdays_property('sunday')
    monday: bool = weekdays_property('monday')
    tuesday: bool = weekdays_property('tuesday')
    wednesday: bool = weekdays_property('wednesday')
    thursday: bool = weekdays_property('thursday')
    friday: bool = weekdays_property('friday')
    saturday: bool = weekdays_property('saturday')

a = Alarm()
fs = [f.name for f in fields(a)]
assert 'timer' in fs, fs
assert 'weekdays' in fs
assert 'sunday' in fs
assert 'monday' in fs
assert 'tuesday' in fs
assert 'wednesday' in fs
assert 'thursday' in fs
assert 'friday' in fs
assert 'saturday' in fs

assert a.timer > now
assert a.weekdays.sunday is False
assert a.weekdays.monday is True
assert a.weekdays.tuesday is False
assert a.sunday is False
assert a.monday is True
assert a.tuesday is False

a = Alarm(timer=now, sunday=True)
assert a.timer == now
assert a.weekdays.sunday is True
assert a.weekdays.monday is True
assert a.weekdays.tuesday is False
assert a.sunday is True
assert a.monday is True
assert a.tuesday is False

Metadata

Release files for dataclass-dateproperty 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataclass-dateproperty 1.0.0
File Size Uploaded
dataclass_dateproperty-1.0.0.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataclass-dateproperty 1.0.0
File Interpreter ABI Platform
dataclass_dateproperty-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.9 kB

Release files / dataclass_dateproperty-1.0.0.tar.gz

Download URL dataclass_dateproperty-1.0.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ec51ce9247df23da6abe40e660bbf19492c47ffdef955acde88648b1795be349
BLAKE2b-256 checksum
How to use checksums
bbbaad31fcfe7ba464a95f8e4fe99682c2ef5c82ccf8d45a08beff56eda178e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

Release files / dataclass_dateproperty-1.0.0-py3-none-any.whl

Download URL dataclass_dateproperty-1.0.0-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfa41d508b4f4598e030a2f69c51b249e5bb72561a963c1cdac0545e76b661af
BLAKE2b-256 checksum
How to use checksums
322bc34a8815ed9290c6f8e36e45b0ca058fcbbf6749a5a54636f742fddd5652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.8

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page