### Get Festivals from Date (Python) Source: https://6tail.cn/calendar/solar.festivals This Python example demonstrates how to get festivals for a specific date using the Solar class. It includes fetching both regular and other festivals and printing them. Assumes the Solar class is available and standard Python print function is used. ```python d = Solar.fromYmd(2016, 1, 1) l = d.getFestivals() for s in l: print s d = Solar.fromYmd(2019, 3, 5) l = d.getOtherFestivals() for s in l: print s ``` -------------------------------- ### Get Festivals from Date (C#) Source: https://6tail.cn/calendar/solar.festivals This C# example demonstrates how to fetch festivals for a specified date using the Solar class. It includes fetching regular and other festivals and outputting them using Console.WriteLine. Requires the Solar class and standard .NET framework functionalities. ```csharp Solar d = Solar.fromYmd(2016, 1, 1); List l = d.getFestivals(); foreach(string s in l) { Console.WriteLine(s); } d = Solar.fromYmd(2019, 3, 5); l = d.getOtherFestivals(); foreach(string s in l) { Console.WriteLine(s); } ``` -------------------------------- ### Example Holiday Data for 2025 (Go) Source: https://6tail.cn/calendar/holiday-util.fix This is an example of the formatted string data for public holidays in 2025, intended for use with the `fix` function. Each segment represents a day's holiday status and type, following the specified 18-digit format. ```text 202501010120250101202501261020250129202501281120250129202501291120250129202501301120250129202501311120250129202502011120250129202502021120250129202502031120250129202502041120250129202502081020250129202504042120250404202504052120250404202504062120250404202504273020250501202505013120250501202505023120250501202505033120250501202505043120250501202505053120250501202505314120250531202506014120250531202506024120250531202509287020251001202510017120251001202510027120251001202510037120251001202510047120251001202510057120251001202510067120251001202510077120251001202510087120251001202510117020251001 ``` -------------------------------- ### Example Holiday Data for 2023 (Go) Source: https://6tail.cn/calendar/holiday-util.fix This is an example of the formatted string data for public holidays in 2023, intended for use with the `fix` function. Each segment represents a day's holiday status and type, following the specified 18-digit format. ```text 202212310120230101202301010120230101202301020120230101202301211120230122202301221120230122202301231120230122202301241120230122202301251120230122202301261120230122202301271120230122202301281020230122202301291020230122202304052120230405202304233020230501202304293120230501202304303120230501202305013120230501202305023120230501202305033120230501202305043120230501202305063020230501202306224120230622202306234120230622202306244120230622202306254020230622202309295120230929202309306120231001202310016120231001202310026120231001202310036120231001202310046120231001202310056120231001202310066120231001202310076020231001202310086020231001 ``` -------------------------------- ### Example Holiday Data for 2022 (Go) Source: https://6tail.cn/calendar/holiday-util.fix This is an example of the formatted string data for public holidays in 2022, intended for use with the `fix` function. Each segment represents a day's holiday status and type, following the specified 18-digit format. ```text 202201010120220101202201020120220101202201030120220101202201291020220201202201301020220201202201311120220201202202011120220201202202021120220201202202031120220201202202041120220201202202051120220201202202061120220201202204022020220405202204032120220405202204042120220405202204052120220405202204243020220501202204303120220501202205013120220501202205023120220501202205033120220501202205043120220501202205073020220501202206034120220603202206044120220603202206054120220603202209105120220910202209115120220910202209125120220910202210016120221001202210026120221001202210036120221001202210046120221001202210056120221001202210066120221001202210076120221001202210086020221001202210096020221001 ``` -------------------------------- ### Example Holiday Data for 2026 (Go) Source: https://6tail.cn/calendar/holiday-util.fix This is an example of the formatted string data for public holidays in 2026, intended for use with the `fix` function. Each segment represents a day's holiday status and type, following the specified 18-digit format. ```text 202601010120260101202601020120260101202601030120260101202601040020260101202602141020260217202602151120260217202602161120260217202602171120260217202602181120260217202602191120260217202602201120260217202602211120260217202602221120260217202602231120260217202602281020260217202604042120260405202604052120260405202604062120260405202605013120260501202605023120260501202605033120260501202605043120260501202605053120260501202605093020260501202606194120260619202606204120260619202606214120260619202609206020261001202609255120260925202609265120260925202609275120260925202610016120261001202610026120261001202610036120261001202610046120261001202610056120261001202610066120261001202610076120261001202610106020261001 ``` -------------------------------- ### Get Auspicious/Inauspicious Activities - C# Source: https://6tail.cn/calendar/lunar.yiji This C# example illustrates fetching auspicious (getDayYi) and inauspicious (getDayJi) activities for the current date via the Lunar class. It processes lists of strings and outputs them using Console.WriteLine. This code assumes the Lunar library is referenced. ```csharp Lunar d = Lunar.fromDate(new Date()); // 宜 List l = d.getDayYi(); foreach(string s in l) { Console.WriteLine(s); } // 忌 l = d.getDayJi(); foreach(string s in l) { Console.WriteLine(s); } ``` -------------------------------- ### Example Holiday Data for 2024 (Go) Source: https://6tail.cn/calendar/holiday-util.fix This is an example of the formatted string data for public holidays in 2024, intended for use with the `fix` function. Each segment represents a day's holiday status and type, following the specified 18-digit format. ```text 202312300120240101202312310120240101202401010120240101202402041020240210202402101120240210202402111120240210202402121120240210202402131120240210202402141120240210202402151120240210202402161120240210202402171120240210202402181020240210202404042120240404202404052120240404202404062120240404202404072020240404202404283020240501202405013120240501202405023120240501202405033120240501202405043120240501202405053120240501202405113020240501202406084120240610202406094120240610202406104120240610202409145020240917202409155120240917202409165120240917202409175120240917202409296020241001202410016120241001202410026120241001202410036120241001202410046120241001202410056120241001202410066120241001202410076120241001202410126020241001 ``` -------------------------------- ### Deleting Holiday Data Example (Go) Source: https://6tail.cn/calendar/holiday-util.fix This example demonstrates how to delete a specific holiday entry, such as the one on January 1, 2010. By setting the 'holiday name index' to '~', the entry is effectively removed. The total string length must be maintained by padding with zeros. ```text 20100101~000000000000000000000000000 ``` -------------------------------- ### Get Eight Char WuXing Example (JavaScript) Source: https://6tail.cn/calendar/lunar.bazi A basic JavaScript example demonstrating how to get the WuXing (Five Elements) for the Year, Month, Day, and Hour pillars from an EightChar object. This requires an instance of the Lunar class initialized from a date. ```javascript var lunar = Lunar.fromDate(new Date()); var eightChar = lunar.getEightChar(); console.log(eightChar.getYearWuXing() + ', ' + eightChar.getMonthWuXing() + ', ' + eightChar.getDayWuXing() + ', ' + eightChar.getTimeWuXing()); ``` -------------------------------- ### Get Festivals from Lunar Date - Python Source: https://6tail.cn/calendar/foto.festivals This Python example demonstrates fetching festivals from a lunar date. It calls the `fromLunar` method on the Foto class and then retrieves the festivals using `getFestivals`. The code iterates through the resulting list and prints the `toFullString` representation of each festival. Ensure the necessary 6tail calendar modules are installed. ```python d = Foto.fromLunar(Lunar.fromYmd(2021, 10, 14)) l = d.getFestivals() for f in l: print f.toFullString() ``` -------------------------------- ### Initialize Tao Calendar and Convert to Lunar (Go) Source: https://6tail.cn/calendar/tao.lunar This snippet demonstrates initializing a Tao calendar from the current date and then converting it to its lunar representation. It prints both the Tao calendar object and its lunar string formats. ```Go // 实例化 tao := calendar.NewTaoFromLunar(calendar.NewLunarFromDate(time.Now())) fmt.Println(tao) // 转阴历 lunar := tao.GetLunar() fmt.Println(lunar.ToString()) fmt.Println(lunar.ToFullString()) ``` -------------------------------- ### Get Ganzhi Year (Lichun Start) Source: https://6tail.cn/calendar/lunar.ganzhi Retrieves the Ganzhi representation for the year, where the year starts from Lichun (Start of Spring). This is an alternative to the standard Lunar New Year calculation and is often used in folk calendars. ```javascript var d = Lunar.fromDate(new Date()); console.log('年天干:'+d.getYearGanByLiChun()); console.log('年地支:'+d.getYearZhiByLiChun()); console.log('年干支:'+d.getYearInGanZhiByLiChun()); ``` -------------------------------- ### Manage Chinese Holidays Across Multiple Languages Source: https://6tail.cn/calendar/holiday-util.fix This snippet demonstrates how to use the HolidayUtil class to modify holidays, add new ones, and retrieve holiday information. It shows how to fix specific dates to holidays and how to rename existing holidays. The examples cover JavaScript, Java, C#, PHP, Python, and Go, showcasing the cross-language compatibility of the utility. ```javascript // 将2020-01-01修改为春节,并追加2099-01-01为元旦节 HolidayUtil.fix('202001011120200101209901010120990101'); console.log(HolidayUtil.getHoliday('2020-01-01')); console.log(HolidayUtil.getHoliday('2099-01-01')); // 将元旦节改为元旦 String[] names = HolidayUtil.NAMES; names[0] = '元旦'; HolidayUtil.fix(names, null); console.log(HolidayUtil.getHoliday('2099-01-01')); ``` ```java // 将2020-01-01修改为春节,并追加2099-01-01为元旦节 HolidayUtil.fix("202001011120200101209901010120990101"); System.out.println(HolidayUtil.getHoliday("2020-01-01")); System.out.println(HolidayUtil.getHoliday("2099-01-01")); // 将元旦节改为元旦 String[] names = HolidayUtil.NAMES; names[0] = "元旦"; HolidayUtil.fix(names, null); System.out.println(HolidayUtil.getHoliday("2099-01-01")); ``` ```csharp // 将2020-01-01修改为春节,并追加2099-01-01为元旦节 HolidayUtil.fix("202001011120200101209901010120990101"); Console.WriteLine(HolidayUtil.getHoliday("2020-01-01")); Console.WriteLine(HolidayUtil.getHoliday("2099-01-01")); // 将元旦节改为元旦 string[] names = HolidayUtil.NAMES; names[0] = "元旦"; HolidayUtil.fix(names, null); Console.WriteLine(HolidayUtil.getHoliday("2099-01-01")); ``` ```php // 将2020-01-01修改为春节,并追加2099-01-01为元旦节 HolidayUtil::fix(null, '202001011120200101209901010120990101'); echo HolidayUtil::getHoliday('2020-01-01'); echo HolidayUtil::getHoliday('2099-01-01'); // 将元旦节改为元旦 $names = HolidayUtil::$NAMES; $names[0] = '元旦'; HolidayUtil::fix($names, null); echo HolidayUtil::getHoliday('2099-01-01'); ``` ```python # 将2020-01-01修改为春节,并追加2099-01-01为元旦节 HolidayUtil.fix(None, "202001011120200101209901010120990101") print(HolidayUtil.getHoliday("2020-01-01")) print(HolidayUtil.getHoliday("2099-01-01")) # 将元旦节改为元旦 names = [] for i in range(0, len(HolidayUtil.NAMES)): names.append(HolidayUtil.NAMES[i]) names[0] = "元旦" HolidayUtil.fix(names, None) print(HolidayUtil.getHoliday("2099-01-01")) ``` ```go # 将2020-01-01修改为春节,并追加2099-01-01为元旦节 HolidayUtil.Fix(nil, "202001011120200101209901010120990101") fmt.Println(HolidayUtil.GetHoliday("2020-01-01")) fmt.Println(HolidayUtil.GetHoliday("2099-01-01")) # 将元旦节改为元旦 names := HolidayUtil.NAMES names[0] = "元旦" HolidayUtil.Fix(names, "") fmt.Println(HolidayUtil.GetHoliday("2099-01-01")) ``` -------------------------------- ### SolarWeek Instantiation Source: https://6tail.cn/calendar/solar-week.new This section describes how to instantiate the SolarWeek object using different methods, including specifying the start of the week. ```APIDOC ## SolarWeek Instantiation This section describes how to instantiate the `SolarWeek` object using different methods: 1. **`SolarWeek.fromYmd(year, month, day, start)`** > Creates a `SolarWeek` object from a given solar year, month, and day. The `start` parameter specifies the first day of the week (1=Monday, 7=Sunday). 2. **`SolarWeek.fromDate(date, start)`** > Creates a `SolarWeek` object from a JavaScript `Date` object. The `start` parameter specifies the first day of the week (1=Monday, 7=Sunday). **Note:** The `start` parameter is crucial as different regions consider Monday or Sunday as the start of the week, which can affect week calculations. ### Request Example ```javascript var d = SolarWeek.fromYmd(2016, 1, 1, 1); console.log(d); console.log(d.toFullString()); ``` ### Response Example ``` 2016.1.1 2016年1月第1周 ``` ``` -------------------------------- ### Get Solar Week Start Day (JavaScript) Source: https://6tail.cn/calendar/solar-week.start Retrieves the starting day of the week for a SolarWeek object. The return value represents Monday to Sunday with values 1-6 and 0 respectively. The actual returned value depends on the start day that was set during instantiation. ```javascript var d = SolarWeek.fromDate(new Date(),1); console.log(d.getStart()); ``` -------------------------------- ### SolarUtil - Get Day of Year Source: https://6tail.cn/calendar/solar-util.daysinyear Calculates the day number of a given date within its year, starting from January 1st. ```APIDOC ## SolarUtil.getDaysInYear ### Description Calculates the day number of a given date within its year, starting from January 1st. For example, January 2nd is the 2nd day of the year, and February 1st is the 32nd day. ### Method `SolarUtil.getDaysInYear(year, month, day)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters (Function Arguments) - **year** (number) - Required - The solar year. - **month** (number) - Required - The solar month. - **day** (number) - Required - The solar day. ### Request Example ```javascript console.log(SolarUtil.getDaysInYear(2016, 3, 1)); ``` ### Response #### Success Response (200) - **dayOfYear** (number) - The day number within the year. ### Response Example ```json 61 ``` ``` -------------------------------- ### 获取阳历节日和纪念日 Source: https://6tail.cn/calendar/solar.festivals 通过 Solar.fromYmd() 实例化一个阳历日期对象,然后调用 getFestivals() 获取节假日列表,或调用 getOtherFestivals() 获取其他纪念日列表。这两个方法返回一个字符串数组,可能包含零个或多个条目。 ```javascript var d = Solar.fromYmd(2016, 1, 1); var l = d.getFestivals(); for (var i=0, j=l.length; i l = d.getFestivals(); for (String s:l){ System.out.println(s); } d = Solar.fromYmd(2019, 3, 5); l = d.getOtherFestivals(); for (String s:l){ System.out.println(s); } ``` ```csharp Solar d = Solar.fromYmd(2016, 1, 1); List l = d.getFestivals(); foreach(string s in l) { Console.WriteLine(s); } d = Solar.fromYmd(2019, 3, 5); l = d.getOtherFestivals(); foreach(string s in l) { Console.WriteLine(s); } ``` ```php $d = Solar::fromYmd(2016, 1, 1); $l = $d->getFestivals(); foreach ($l as $s) { echo $s . " "; } $d = Solar::fromYmd(2019, 3, 5); $l = $d->getOtherFestivals(); foreach ($l as $s) { echo $s . " "; } ``` ```python d = Solar.fromYmd(2016, 1, 1) l = d.getFestivals() for s in l: print s d = Solar.fromYmd(2019, 3, 5) l = d.getOtherFestivals() for s in l: print s ``` ```go d := calendar.NewSolarFromYmd((2016, 1, 1) l := d.GetFestivals() for i := l.Front(); i != nil; i = i.Next() { fmt.Println(i.Value.(string)) } d = calendar.NewSolarFromYmd((2019, 3, 5) l = d.GetOtherFestivals() for i := l.Front(); i != nil; i = i.Next() { fmt.Println(i.Value.(string)) } ``` -------------------------------- ### Instantiate Lunar Object from Year, Month, Day in Go Source: https://6tail.cn/calendar/lunar.new Provides a Go example for creating a Lunar object using `calendar.NewLunarFromYmd`. Requires lunar year, month (1-12, negative for leap months), and day. Outputs the object and its full string representation. ```go d := calendar.NewLunarFromYmd(1986, 4, 21) fmt.Println(d) fmt.Println(d.ToFullString()) ``` -------------------------------- ### Lunar Object - Getting Xun Source: https://6tail.cn/calendar/lunar.xun Methods to retrieve the Xun (旬) for a given Lunar date, with variations based on the definition of the start of the year or a solar term. ```APIDOC ## Lunar Object - Getting Xun ### Description Methods to retrieve the Xun (旬) for a given Lunar date, with variations based on the definition of the start of the year or a solar term. ### Methods - `.getYearXun()`: Gets the Xun for the year, starting from the first day of the Lunar New Year. - `.getYearXunByLiChun()`: Gets the Xun for the year, starting from Lichun (Start of Spring). - `.getYearXunExact()`: Gets the Xun for the year, starting from the exact moment of Lichun. - `.getMonthXun()`: Gets the Xun for the month, calculated from the start of a solar term. - `.getMonthXunExact()`: Gets the Xun for the month, calculated from the exact moment of a solar term. - `.getDayXun()`: Gets the Xun for the day, calculated from the start of a solar term. - `.getDayXunExact()`: Gets the Xun for the day, calculated from the exact moment of a solar term (counts the next day after midnight). - `.getTimeXun()`: Gets the Xun for the time period (辰). ### Request Example ```javascript var d = Lunar.fromDate(new Date()); console.log('Year Xun: ' + d.getYearXun()); ``` ### Response Example ```json { "xun": "甲子" } ``` ``` -------------------------------- ### Get Auspicious/Inauspicious Activities - Python Source: https://6tail.cn/calendar/lunar.yiji This Python example shows how to get the current date's auspicious (getDayYi) and inauspicious (getDayJi) activities using the Lunar class. It iterates through the returned lists and prints each activity. This code relies on the Lunar library and Python's datetime module. ```python d = Lunar.fromDate(datetime.now()) # 宜 l = d.getDayYi() for s in l: print s # 忌 l = d.getDayJi() for s in l: print s ``` -------------------------------- ### Lunar Object - Getting XunKong Source: https://6tail.cn/calendar/lunar.xun Methods to retrieve the XunKong (旬空 - emptiness) for a given Lunar date, with variations based on the definition of the start of the year or a solar term. ```APIDOC ## Lunar Object - Getting XunKong ### Description Methods to retrieve the XunKong (旬空 - emptiness) for a given Lunar date, with variations based on the definition of the start of the year or a solar term. ### Methods - `.getYearXunKong()`: Gets the XunKong for the year, starting from the first day of the Lunar New Year. - `.getYearXunKongByLiChun()`: Gets the XunKong for the year, starting from Lichun (Start of Spring). - `.getYearXunKongExact()`: Gets the XunKong for the year, starting from the exact moment of Lichun. - `.getMonthXunKong()`: Gets the XunKong for the month, calculated from the start of a solar term. - `.getMonthXunKongExact()`: Gets the XunKong for the month, calculated from the exact moment of a solar term. - `.getDayXunKong()`: Gets the XunKong for the day, calculated from the start of a solar term. - `.getDayXunKongExact()`: Gets the XunKong for the day, calculated from the exact moment of a solar term (counts the next day after midnight). - `.getTimeXunKong()`: Gets the XunKong for the time period (辰). ### Request Example ```javascript var d = Lunar.fromDate(new Date()); console.log('Year XunKong: ' + d.getYearXunKong()); ``` ### Response Example ```json { "xunKong": "戌亥" } ``` ``` -------------------------------- ### Get Festivals from Lunar Date - C# Source: https://6tail.cn/calendar/foto.festivals This C# example shows how to obtain festivals from a specific lunar date. It utilizes the Foto and Lunar classes to get the festivals and then iterates through them, printing their full string representation to the console. This requires the relevant 6tail calendar libraries to be referenced. ```csharp var d = Foto.FromLunar(Lunar.FromYmd(2021, 10, 14)); var l = d.Festivals; foreach(var f in l) { Console.WriteLine(f.FullString); } ``` -------------------------------- ### Tao Calendar: Get Year, Month, Day Source: https://6tail.cn/calendar/tao.ymd This section details how to retrieve the year, month, and day from the Tao calendar in both numeric and Chinese representations. It also provides code examples in multiple languages. ```APIDOC ## Tao Calendar: Get Year, Month, Day ### Description Retrieves the year, month, and day from a Tao calendar instance. Supports both numeric and Chinese representations. ### Method N/A (This describes object methods) ### Endpoint N/A ### Parameters None for this specific operation, but assumes a Tao calendar object is instantiated. ### Request Example ```javascript // Assuming 'd' is an instantiated Tao object console.log(d.getYear()); console.log(d.getMonth()); console.log(d.getDay()); console.log(d.getYearInChinese()); console.log(d.getMonthInChinese()); console.log(d.getDayInChinese()); ``` ### Response #### Success Response - **Year** (number | string) - The year in numeric or Chinese format. - **Month** (number | string) - The month in numeric or Chinese format. For numeric, leap months are negative. - **Day** (number | string) - The day in numeric or Chinese format. #### Response Example ```json { "year": 2023, "month": 10, "day": 26, "yearInChinese": "癸卯年", "monthInChinese": "十月", "dayInChinese": "廿六" } ``` ``` -------------------------------- ### Instantiate Lunar Object from Year, Month, Day in C# Source: https://6tail.cn/calendar/lunar.new Provides a C# example for creating a Lunar object using the `fromYmd` static method. This requires specifying the lunar year, month (1-12, negative for leap months), and day as integers. The code prints the object and its full string representation. ```csharp Lunar d = Lunar.fromYmd(1986, 4, 21); Console.WriteLine(d); Console.WriteLine(d.toFullString()); ``` -------------------------------- ### Get Festivals from Lunar Date - Go Source: https://6tail.cn/calendar/foto.festivals This Go code snippet shows how to get festivals from a lunar date. It initializes a Foto object from a lunar date and then retrieves the list of festivals. The code iterates through the linked list of festivals and prints their full string representation using `fmt.Println`. This example assumes the 'calendar' package is available. ```go d := calendar.NewFotoFromLunar(calendar.NewLunarFromYmd(2021, 10, 14)) l := d.GetFestivals() for i := l.Front(); i != nil; i = i.Next() { fmt.Println(i.Value.(*calendar.FotoFestival).ToFullString()) } ``` -------------------------------- ### Instantiate Lunar Object from Year, Month, Day in Python Source: https://6tail.cn/calendar/lunar.new Provides a Python example for creating a Lunar object using the `fromYmd` method. Requires lunar year, month (1-12, negative for leap months), and day as integers. Outputs the object and its full string representation. ```python d = Lunar.fromYmd(1986, 4, 21) print d print d.toFullString() ``` -------------------------------- ### Get Weeks of a Solar Month (JavaScript) Source: https://6tail.cn/calendar/solar-month.weeks Retrieves an array of SolarWeek objects representing each week within a SolarMonth object. The starting day of the week can be specified. This function is useful for iterating through weeks of a given month. ```javascript var d = SolarMonth.fromDate(new Date()); var weeks = d.getWeeks(1); for(var i=0,j=weeks.length;i