0
# Buddhist and Taoist Calendars
1
2
Specialized calendar systems for Buddhist (Foto) and Taoist (Tao) traditions, providing religious festival calculations, fasting days, and spiritual observances according to traditional Chinese religious practices.
3
4
## Capabilities
5
6
### Buddhist Calendar (佛历)
7
8
Traditional Buddhist calendar system with comprehensive festival and observance calculations.
9
10
```python { .api }
11
class Foto:
12
@staticmethod
13
def fromLunar(lunar: 'Lunar') -> 'Foto': ...
14
15
def getLunar(self) -> 'Lunar': ... # Get associated lunar date
16
```
17
18
#### Buddhist Festivals
19
20
Calculation of traditional Buddhist festivals and important observance days.
21
22
```python { .api }
23
class Foto:
24
def getFestivals(self) -> list: ... # List of FotoFestival objects for this date
25
def getOtherFestivals(self) -> list: ... # Other Buddhist observances
26
27
class FotoFestival:
28
def __init__(self, name: str, result: str = None): ...
29
30
def getName(self) -> str: ... # Festival name
31
def setName(self, name: str): ...
32
def getResult(self) -> str: ... # Festival description/result
33
def setResult(self, result: str): ...
34
def toString(self) -> str: ...
35
```
36
37
#### Buddhist Constellations (星宿)
38
39
Traditional 28 constellation system used in Buddhist calendar calculations.
40
41
```python { .api }
42
class Foto:
43
def getXiu(self) -> str: ... # Current constellation name
44
def getXiuLuck(self) -> str: ... # Constellation luck classification
45
def getXiuSong(self) -> str: ... # Constellation verse/song
46
def getZheng(self) -> str: ... # Government/direction
47
def getAnimal(self) -> str: ... # Associated animal
48
def getGong(self) -> str: ... # Palace/location
49
def getShou(self) -> str: ... # Guardian/protector
50
```
51
52
#### Buddhist String Representation
53
54
```python { .api }
55
class Foto:
56
def toString(self) -> str: ... # Basic Buddhist date string
57
def toFullString(self) -> str: ... # Complete Buddhist calendar description
58
```
59
60
### Taoist Calendar (道历)
61
62
Traditional Taoist calendar system for Taoist festivals and spiritual observances.
63
64
```python { .api }
65
class Tao:
66
@staticmethod
67
def fromLunar(lunar: 'Lunar') -> 'Tao': ...
68
69
def getLunar(self) -> 'Lunar': ... # Get associated lunar date
70
```
71
72
#### Taoist Festivals
73
74
Calculation of traditional Taoist festivals and important spiritual observance days.
75
76
```python { .api }
77
class Tao:
78
def getFestivals(self) -> list: ... # List of TaoFestival objects for this date
79
80
class TaoFestival:
81
def __init__(self, name: str, result: str = None): ...
82
83
def getName(self) -> str: ... # Festival name
84
def setName(self, name: str): ...
85
def getResult(self) -> str: ... # Festival description/result
86
def setResult(self, result: str): ...
87
def toString(self) -> str: ...
88
```
89
90
#### Taoist String Representation
91
92
```python { .api }
93
class Tao:
94
def toString(self) -> str: ... # Basic Taoist date string
95
def toFullString(self) -> str: ... # Complete Taoist calendar description
96
```
97
98
### Religious Calendar Utilities
99
100
Utility functions for Buddhist and Taoist calendar calculations.
101
102
#### Buddhist Utilities (FotoUtil)
103
104
```python { .api }
105
class FotoUtil:
106
# Buddhist constellation calculation
107
@staticmethod
108
def getXiu(month: int, day: int) -> str: ...
109
110
# Fasting day calculations
111
@staticmethod
112
def getDayYi(monthGanZhi: str, dayGanZhi: str) -> list: ...
113
@staticmethod
114
def getDayJi(monthGanZhi: str, dayGanZhi: str) -> list: ...
115
```
116
117
#### Taoist Utilities (TaoUtil)
118
119
```python { .api }
120
class TaoUtil:
121
# Taoist festival calculations
122
@staticmethod
123
def getFestival(month: int, day: int) -> list: ...
124
```
125
126
## Usage Examples
127
128
### Basic Buddhist Calendar Usage
129
130
```python
131
from lunar_python import Lunar, Foto
132
133
# Create lunar date
134
lunar = Lunar.fromYmd(2023, 4, 8) # Traditional Buddha's Birthday
135
136
# Get Buddhist calendar equivalent
137
foto = Foto.fromLunar(lunar)
138
139
print("=== Buddhist Calendar ===")
140
print(f"Buddhist date: {foto.toString()}")
141
print(f"Full description: {foto.toFullString()}")
142
143
# Get Buddhist festivals
144
festivals = foto.getFestivals()
145
if festivals:
146
print("\nBuddhist Festivals:")
147
for festival in festivals:
148
print(f" {festival.getName()}: {festival.getResult()}")
149
150
other_festivals = foto.getOtherFestivals()
151
if other_festivals:
152
print("\nOther Buddhist Observances:")
153
for festival in other_festivals:
154
print(f" {festival.getName()}: {festival.getResult()}")
155
```
156
157
### Buddhist Constellation Analysis
158
159
```python
160
from lunar_python import Lunar, Foto
161
162
lunar = Lunar.fromYmd(2023, 4, 11)
163
foto = Foto.fromLunar(lunar)
164
165
print("=== Buddhist Constellation Analysis ===")
166
print(f"Constellation (星宿): {foto.getXiu()}")
167
print(f"Luck classification: {foto.getXiuLuck()}")
168
print(f"Constellation verse: {foto.getXiuSong()}")
169
print(f"Direction: {foto.getZheng()}")
170
print(f"Associated animal: {foto.getAnimal()}")
171
print(f"Palace: {foto.getGong()}")
172
print(f"Guardian: {foto.getShou()}")
173
```
174
175
### Basic Taoist Calendar Usage
176
177
```python
178
from lunar_python import Lunar, Tao
179
180
# Create lunar date
181
lunar = Lunar.fromYmd(2023, 1, 9) # Jade Emperor's Birthday
182
183
# Get Taoist calendar equivalent
184
tao = Tao.fromLunar(lunar)
185
186
print("=== Taoist Calendar ===")
187
print(f"Taoist date: {tao.toString()}")
188
print(f"Full description: {tao.toFullString()}")
189
190
# Get Taoist festivals
191
festivals = tao.getFestivals()
192
if festivals:
193
print("\nTaoist Festivals:")
194
for festival in festivals:
195
print(f" {festival.getName()}: {festival.getResult()}")
196
```
197
198
### Religious Festival Survey
199
200
```python
201
from lunar_python import Lunar, Foto, Tao
202
203
# Survey a date for all religious observances
204
lunar = Lunar.fromYmd(2023, 4, 8)
205
206
print(f"=== Religious Observances for {lunar.toString()} ===")
207
208
# Buddhist observances
209
foto = Foto.fromLunar(lunar)
210
buddhist_festivals = foto.getFestivals() + foto.getOtherFestivals()
211
if buddhist_festivals:
212
print("\nBuddhist:")
213
for festival in buddhist_festivals:
214
print(f" • {festival.getName()}")
215
216
# Taoist observances
217
tao = Tao.fromLunar(lunar)
218
taoist_festivals = tao.getFestivals()
219
if taoist_festivals:
220
print("\nTaoist:")
221
for festival in taoist_festivals:
222
print(f" • {festival.getName()}")
223
224
# If no religious festivals
225
if not buddhist_festivals and not taoist_festivals:
226
print("\nNo major religious festivals on this date.")
227
```
228
229
### Monthly Religious Calendar
230
231
```python
232
from lunar_python import Lunar, Foto, Tao, LunarMonth
233
234
# Get all religious festivals in a lunar month
235
lunar_month = LunarMonth.fromYm(2023, 4) # 4th lunar month
236
days_in_month = lunar_month.getDayCount()
237
238
print(f"=== Religious Calendar for Lunar Month 4, 2023 ===")
239
240
religious_days = []
241
242
for day in range(1, days_in_month + 1):
243
lunar = Lunar.fromYmd(2023, 4, day)
244
245
# Check Buddhist festivals
246
foto = Foto.fromLunar(lunar)
247
buddhist = foto.getFestivals() + foto.getOtherFestivals()
248
249
# Check Taoist festivals
250
tao = Tao.fromLunar(lunar)
251
taoist = tao.getFestivals()
252
253
if buddhist or taoist:
254
religious_days.append({
255
'day': day,
256
'lunar': lunar,
257
'buddhist': buddhist,
258
'taoist': taoist
259
})
260
261
# Display religious days
262
for info in religious_days:
263
print(f"\nDay {info['day']} ({info['lunar'].getSolar().toYmd()}):")
264
265
if info['buddhist']:
266
print(" Buddhist:")
267
for festival in info['buddhist']:
268
print(f" • {festival.getName()}")
269
270
if info['taoist']:
271
print(" Taoist:")
272
for festival in info['taoist']:
273
print(f" • {festival.getName()}")
274
```
275
276
### Constellation Cycle Analysis
277
278
```python
279
from lunar_python import Lunar, Foto
280
281
# Analyze constellation changes over a period
282
print("=== 28-Day Constellation Cycle ===")
283
284
base_lunar = Lunar.fromYmd(2023, 4, 1)
285
286
for i in range(28): # 28 constellations
287
current_lunar = base_lunar.next(i)
288
foto = Foto.fromLunar(current_lunar)
289
290
constellation = foto.getXiu()
291
luck = foto.getXiuLuck()
292
animal = foto.getAnimal()
293
294
print(f"Day {i+1:2d}: {constellation:3s} ({luck:2s}) - {animal}")
295
```
296
297
### Religious Calendar Integration
298
299
```python
300
from lunar_python import Lunar, Foto, Tao
301
302
def get_religious_info(lunar_date):
303
"""Get comprehensive religious calendar information."""
304
305
# Basic date info
306
solar = lunar_date.getSolar()
307
print(f"Date: {solar.toYmd()} ({lunar_date.toString()})")
308
309
# Buddhist calendar
310
foto = Foto.fromLunar(lunar_date)
311
print(f"Buddhist: {foto.toFullString()}")
312
313
buddhist_festivals = foto.getFestivals() + foto.getOtherFestivals()
314
if buddhist_festivals:
315
print(" Festivals:")
316
for festival in buddhist_festivals:
317
print(f" {festival.getName()}")
318
319
# Taoist calendar
320
tao = Tao.fromLunar(lunar_date)
321
print(f"Taoist: {tao.toFullString()}")
322
323
taoist_festivals = tao.getFestivals()
324
if taoist_festivals:
325
print(" Festivals:")
326
for festival in taoist_festivals:
327
print(f" {festival.getName()}")
328
329
# Example usage
330
lunar = Lunar.fromYmd(2023, 4, 8) # Buddha's Birthday
331
get_religious_info(lunar)
332
```
333
334
### Fasting Day Calculations
335
336
```python
337
from lunar_python import Lunar, Foto
338
from lunar_python.util import FotoUtil
339
340
# Traditional Buddhist fasting days (1st, 8th, 14th, 15th, 18th, 23rd, 24th, 28th-30th)
341
def is_buddhist_fasting_day(lunar_date):
342
"""Check if a lunar date is a traditional Buddhist fasting day."""
343
day = lunar_date.getDay()
344
345
# Common fasting days
346
fasting_days = [1, 8, 14, 15, 18, 23, 24]
347
348
# End of month fasting days (varies by month length)
349
lunar_month = lunar_date.getMonth()
350
lunar_year = lunar_date.getYear()
351
from lunar_python import LunarMonth
352
month_obj = LunarMonth.fromYm(lunar_year, lunar_month)
353
days_in_month = month_obj.getDayCount()
354
355
if days_in_month == 29:
356
fasting_days.extend([28, 29])
357
else: # 30 days
358
fasting_days.extend([28, 29, 30])
359
360
return day in fasting_days
361
362
# Check several dates
363
test_dates = [
364
Lunar.fromYmd(2023, 4, 1), # 1st - fasting day
365
Lunar.fromYmd(2023, 4, 8), # 8th - fasting day
366
Lunar.fromYmd(2023, 4, 15), # 15th - fasting day
367
Lunar.fromYmd(2023, 4, 16), # 16th - not fasting day
368
]
369
370
print("=== Buddhist Fasting Day Analysis ===")
371
for lunar in test_dates:
372
is_fasting = is_buddhist_fasting_day(lunar)
373
status = "Fasting Day" if is_fasting else "Regular Day"
374
print(f"{lunar.toString()} - {status}")
375
```