Skip to content

Commit

Permalink
📝 Update document.Fix #52
Browse files Browse the repository at this point in the history
  • Loading branch information
kinegratii committed Jan 12, 2024
1 parent 7b569d9 commit ae2b502
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
28 changes: 15 additions & 13 deletions borax/calendars/festivals2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import collections
import csv
import enum
import warnings
from datetime import date, timedelta, datetime
from pathlib import Path
import warnings
from typing import List, Tuple, Optional, Union, Iterator, Set, Generator, Sequence

from borax.calendars.lunardate import LunarDate, LCalendars, TermUtils, TextUtils, TERMS_CN
Expand All @@ -22,11 +22,25 @@
MixedDate = Union[date, LunarDate]


# Public Constants

class FreqConst:
YEARLY = 0
MONTHLY = 1


class FestivalCatalog:
basic = 'basic'
event = 'event'
life = 'life'
public = 'public'
tradition = 'tradition'
term = 'term'
other = 'other'

CATALOGS = ['basic', 'term', 'public', 'tradition', 'event', 'life', 'other']


# Private Global Variables

_IGNORE_LEAP_MONTH = 3
Expand All @@ -47,18 +61,6 @@ class FestivalSchema(enum.IntEnum):
TERM = 4


class FestivalCatalog:
basic = 'basic'
event = 'event'
life = 'life'
public = 'public'
tradition = 'tradition'
term = 'term'
other = 'other'

CATALOGS = ['basic', 'term', 'public', 'tradition', 'event', 'life', 'other']


class WrappedDate:
"""A date object with solar and lunar calendars."""
__slots__ = ['solar', 'lunar', 'name', '_fl']
Expand Down
2 changes: 1 addition & 1 deletion borax/capp/borax_calendar_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from borax.calendars.festivals2 import FestivalLibrary, WrappedDate
from borax.calendars.lunardate import TextUtils, TERMS_CN
from borax.calendars.ui import CalendarFrame, FestivalTableFrame
from borax.capp.festival_creator import FestivalCreatePanel, start_festival_creator
from borax.capp.festival_creator import FestivalCreatePanel

library = FestivalLibrary.load_builtin().sort_by_countdown()

Expand Down
2 changes: 2 additions & 0 deletions docs/guides/festivals2-serialize.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> 模块: `borax.calendars.festivals2`
> Updated in 3.6.0:LunarDate类不再支持直接序列,必须先转化对应的 WrappedDate 对象。
>
> Updated in 3.5.6: 星期型节日(WeekFestival)类支持倒数序号。如:“国际麻风节(1月最后一个星期天)”
>
> Add in 3.5.0
Expand Down
32 changes: 24 additions & 8 deletions docs/guides/festivals2.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

### 常量定义

`festival2` 定义了一些常量,这些常量通常归属于一个名称以“Const”结尾的类,并使用大写字母的变量命名形式。
`festival2` 定义了一些常量,这些常量通常归属于一个类,并使用大写字母的变量命名形式。本文档仅列出那些属于 public 权限的常量类

#### FreqConst

Expand All @@ -26,16 +26,32 @@ FreqConst 表示节日的频率,用于设置 `Festival` 的 `freq` 参数。
| FreqConst.YEARLY = 0 | 表示每年 |
| FreqConst.MONTHLY = 1 | 表示每月 |

#### LeapConst
#### FestivalCatalog

LeapConst表示农历闰月的标志,用于 `Period``Festival` 对象初始化操作
FestivalCatalog 定义了一些节日的分类标签,可以通过 `Festival.catalog` 属性进行读写

| 定义 | 表示 |
| -------------------- | ---- |
| LeapConst.NORMAL = 0 | 平月 |
| LeapConst.LEAP = 1 | 闰月 |
| LeapConst.MIXED = 2 | 混合 |
默认支持以下标签。

```python
class FestivalCatalog:
basic = 'basic'
event = 'event'
life = 'life'
public = 'public'
tradition = 'tradition'
term = 'term'
other = 'other'

CATALOGS = ['basic', 'term', 'public', 'tradition', 'event', 'life', 'other']
```

节日标签用于同一日期有多个节日时,这些节日之间的先后排序问题。

```python
amy_birthday = SolarFestival(month=10,day=1, catalog='event')
```

如上例子,`amy_birthday` 总是在国庆节(其标签为 basic)之后。

## 基础数据结构 - WrappedDate

Expand Down

0 comments on commit ae2b502

Please sign in to comment.