2022-12-11 16:35:27 +02:00
|
|
|
# FixedCal
|
|
|
|
|
2022-12-11 14:54:24 +00:00
|
|
|
[](https://github.com/PyryL/fixedcal/actions)
|
|
|
|
|
2022-12-11 16:35:27 +02:00
|
|
|
Python package for international fixed calendar dates.
|
|
|
|
|
|
|
|
## What is that?
|
|
|
|
|
2022-12-11 14:43:22 +00:00
|
|
|
International fixed calendar is an alternative calendar system.
|
|
|
|
It divides year into 13 even months by adding a month called Sol between June and July.
|
|
|
|
Each month starts with Sunday and has exactly 28 days or 4 weeks.
|
|
|
|
An additional _year day_ is added to the end of the year and it does not belong to any of the months and has no weekday.
|
|
|
|
You can read more about IFC on [Wikipedia](https://en.wikipedia.org/wiki/International_Fixed_Calendar).
|
2022-12-11 16:35:27 +02:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Date initialization
|
|
|
|
|
|
|
|
```python3
|
|
|
|
from fixedcal import FixedDate
|
|
|
|
|
|
|
|
# Date of today
|
|
|
|
fixed_date = FixedDate.today()
|
|
|
|
|
|
|
|
# From native datetime
|
2022-12-12 19:52:44 +02:00
|
|
|
import datetime
|
|
|
|
february_seventh = datetime.date(2022, 2, 7)
|
2022-12-11 14:43:22 +00:00
|
|
|
fixed_date = FixedDate(february_seventh)
|
2022-12-11 16:35:27 +02:00
|
|
|
|
|
|
|
# From day's ordinal in year
|
|
|
|
fixed_date = FixedDate(day_of_year=107, year=2022)
|
|
|
|
```
|
|
|
|
|
|
|
|
### Date's properties
|
|
|
|
|
|
|
|
```python3
|
|
|
|
from fixedcal import FixedDate
|
2022-12-12 19:52:44 +02:00
|
|
|
import datetime
|
|
|
|
fixed_date = FixedDate(datetime.date(2022, 8, 12))
|
2022-12-11 16:35:27 +02:00
|
|
|
|
2022-12-12 19:52:44 +02:00
|
|
|
fixed_date.date # datetime.date(2022, 8, 12)
|
2022-12-11 14:43:22 +00:00
|
|
|
fixed_date.day_of_year # 224
|
|
|
|
fixed_date.day_of_month # 28
|
|
|
|
fixed_date.month # 8
|
|
|
|
fixed_date.year # 2022
|
|
|
|
fixed_date.is_year_day # False
|
2022-12-12 17:26:38 +00:00
|
|
|
fixed_date.is_leap_day # False
|
|
|
|
fixed_date.is_leap_year # False
|
2022-12-11 14:43:22 +00:00
|
|
|
fixed_date.week_of_month # 4
|
|
|
|
fixed_date.weekday # 7
|
|
|
|
fixed_date.week_of_year # 32
|
|
|
|
fixed_date.year_quarter # 3
|
2022-12-11 16:35:27 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Date's operations
|
|
|
|
|
|
|
|
```python3
|
|
|
|
from fixedcal import FixedDate
|
2022-12-12 19:52:44 +02:00
|
|
|
from datetime import date, timedelta
|
2022-12-12 17:26:38 +00:00
|
|
|
|
2022-12-12 19:52:44 +02:00
|
|
|
fixed_date = FixedDate(date(2022, 12, 6))
|
|
|
|
jan_first = FixedDate(date(2023, 1, 1))
|
2022-12-11 16:35:27 +02:00
|
|
|
|
2022-12-12 17:26:38 +00:00
|
|
|
str(fixed_date) # 2022-13-04
|
|
|
|
|
2022-12-11 14:43:22 +00:00
|
|
|
new_fixed = fixed_date + timedelta(3) # FixedDate 3 days ahead
|
|
|
|
new_fixed = fixed_date - timedelta(2) # FixedDate 2 days before
|
|
|
|
new_fixed = jan_first - fixed_date # timedelta between dates
|
2022-12-11 16:35:27 +02:00
|
|
|
|
2022-12-11 14:43:22 +00:00
|
|
|
fixed_date == fixed_date # True
|
|
|
|
fixed_date != jan_first # True
|
|
|
|
jan_first < fixed_date # False
|
2022-12-11 16:35:27 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Year day
|
|
|
|
|
2022-12-11 14:43:22 +00:00
|
|
|
Year day is the day after the last of December and before the first of January.
|
|
|
|
For that date, `FixedDate` gives the following property values.
|
2022-12-11 16:35:27 +02:00
|
|
|
|
2022-12-11 18:54:02 +02:00
|
|
|
* `day_of_year` = 365 (366 on leap years)
|
|
|
|
* `day_of_month` = 29
|
|
|
|
* `month` = 13
|
2022-12-11 16:35:27 +02:00
|
|
|
* `year` is obviously the ending year
|
|
|
|
* `is_year_day` = True
|
2022-12-11 18:54:02 +02:00
|
|
|
* `week_of_month` = 4
|
|
|
|
* `weekday` = None
|
|
|
|
* `week_of_year` = 52
|
2022-12-11 16:35:27 +02:00
|
|
|
* `year_quarter` = 4
|