Skip to main content

Weekdays and datetime properties for the dataclass_property library.

Project description

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

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

dataclass_dateproperty-1.0.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

dataclass_dateproperty-1.0.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file dataclass_dateproperty-1.0.0.tar.gz.

File metadata

  • Download URL: dataclass_dateproperty-1.0.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for dataclass_dateproperty-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ec51ce9247df23da6abe40e660bbf19492c47ffdef955acde88648b1795be349
MD5 a0f351acd7ef495fd6a0445a5623b683
BLAKE2b-256 bbbaad31fcfe7ba464a95f8e4fe99682c2ef5c82ccf8d45a08beff56eda178e9

See more details on using hashes here.

File details

Details for the file dataclass_dateproperty-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dataclass_dateproperty-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for dataclass_dateproperty-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfa41d508b4f4598e030a2f69c51b249e5bb72561a963c1cdac0545e76b661af
MD5 19f8d88e0bd7a39cf6306bfc51e00f7f
BLAKE2b-256 322bc34a8815ed9290c6f8e36e45b0ca058fcbbf6749a5a54636f742fddd5652

See more details on using hashes here.

Supported by

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