Metadata-Version: 2.4
Name: weekdays-enum
Version: 0.1.1
Summary: A super lightweight thoroughly tested package to make dealing with the days of a week a little easier.
Author-email: storm-g <storm-g-code@proton.me>
License-Expression: MIT
Project-URL: Repository, https://bitbucket.org/storm-g-za/week-days
Keywords: enum,day,date,datetime,week,weekday
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: ordered-str-enum>0.1.2
Requires-Dist: packaging
Dynamic: license-file

### weekdays-enum
A super lightweight thoroughly tested package to make dealing with the days of a week a little easier.

Far too often I see hard coded lists of strings representing the days of the week `days = ['Monday', 'Tuesday', ...]`,
or imports of unnecessarily large and often out of date packages just to deal with days of the week coming from
something like json or user input. `weekdays-enum` aims to solve these issues and more.

*Note* `weekdays-enum` depends on one, even smaller, dependency by the same auther:
[ordered-string-enum](https://pypi.org/project/ordered-str-enum/)

See the sourcecode [here](https://bitbucket.org/storm-g-za/week-days).

### Installation
```commandline
pip install weekdays-enum
```

### Usage
The `weekdays-enum` package provides two enum class definitions called `WeekDay` one for weeks starting on Monday, the other
for starting on Sunday. Import the `WeekDay` needed or create your own implementation by extending `WeekDayBase`.

```python
from weekdays.monday_start import WeekDay
# Or if weeks start on Sunday
from weekdays.sunday_start import WeekDay

# Or implement your own
from weekdays.weekday_base import WeekDayBase

class MyWeekDay(WeekDayBase):
  Wednesday = 0
  Thursday  = 1
  ...
```
You can also import specific days
```python
from weekdays.monday_start import Monday, Tuesday
```
or just all the days to use without `WeekDay.`
```python
from weekdays.monday_start import *

print(Monday)
```
### Comparisons and Ordering
`WeekDay` enums are powerful in that they can be retrieved in a number of convenient ways and can be seamlessly compared
with each-other, their int values, or even strings:
```python
import datetime
from weekdays.monday_start import *

print('Compare Monday to Tuesday in 4 equivalent ways')
print(Monday < Tuesday)   # - True
print(Monday < 1)         # - True
print(Monday < 'Tuesday') # - True
print(Monday < 'tuesday') # - True

print('Get the WeekDay easily and intuitively')
first_Monday_2026 = datetime.datetime(2026, 1, 5)
print(WeekDay(0))                               # - <WeekDay.Monday: 0>
print(WeekDay('Monday'))                        # - <WeekDay.Monday: 0>
print(WeekDay('monday'))                        # - <WeekDay.Monday: 0>
print(WeekDay.get_week_day(first_Monday_2026))  # - <WeekDay.Monday: 0>
print(WeekDay.from_iso_day(1))                  # - <WeekDay.Monday: 0>
```
No more hard coding a list of the days of the week. We can get an ordered list from `WeekDay` and a desired string
representing each day:
```python
from weekdays.monday_start import *
days = WeekDay.list() # gets an ordered list containing each day

for day in days:
  print(f'{day.name} or "{day.short()}" for short or "{day.short(2)}" for even shorter')
```
Outputs:
```terminaloutput
Monday or "Mon" for short or "Mo" for even shorter
Tuesday or "Tue" for short or "Tu" for even shorter
Wednesday or "Wed" for short or "We" for even shorter
Thursday or "Thu" for short or "Th" for even shorter
Friday or "Fri" for short or "Fr" for even shorter
Saturday or "Sat" for short or "Sa" for even shorter
Sunday or "Sun" for short or "Su" for even shorter
```
