### Create SolarWeek Instance Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Creates a SolarWeek instance from year, month, week, and start day of the week. The start parameter defines the first day of the week (1 for Monday, 7 for Sunday). ```go func (SolarWeek) FromYm(year int, month int, week int, start int) (*SolarWeek, error) ``` -------------------------------- ### Get SixtyCycleYear Key Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Retrieves the associated SixtyCycle, the first month (starting at spring), and Jupiter's direction for a given SixtyCycleYear. ```go func (o SixtyCycleYear) GetSixtyCycle() SixtyCycle func (o SixtyCycleYear) GetFirstMonth() SixtyCycleMonth func (o SixtyCycleYear) GetJupiterDirection() Direction ``` -------------------------------- ### Import Tyme4go Library Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Import the main tyme package to start using the library's functionalities. ```go import "github.com/6tail/tyme4go/tyme" ``` -------------------------------- ### HijriMonth Key Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/islamic-calendar.md Provides methods to get the day count, year, and month for a HijriMonth. ```go func (o HijriMonth) GetDayCount() int func (o HijriMonth) GetYear() int func (o HijriMonth) GetMonth() int ``` -------------------------------- ### Example: Print Recommended and Avoided Activities Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Demonstrates fetching and printing both recommended and avoided activities for a given day. It iterates through the results and prints their names. ```go recommends, _ := tyme.Taboo{}.GetDayRecommends(monthCycle, dayCycle) avoids, _ := tyme.Taboo{}.GetDayAvoids(monthCycle, dayCycle) fmt.Println("宜(Recommended):") for _, r := range recommends { fmt.Println(" " + r.GetName()) } fmt.Println("忌(Avoid):") for _, a := range avoids { fmt.Println(" " + a.GetName()) } ``` -------------------------------- ### Example Usage of SolarDay Utility Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Demonstrates how to use utility methods like GetName and GetIndexInYear on a SolarDay instance. Shows how to retrieve the SolarMonth as well. ```go day, _ := tyme.SolarDay{}.FromYmd(2020, 3, 15) fmt.Println(day.GetName()) // 15日 fmt.Println(day.GetIndexInYear()) // 74 (75th day of year) month := day.GetSolarMonth() ``` -------------------------------- ### Configuration Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Information on setting up and configuring the tyme4go library, including package setup, constants, supported date ranges, and extension interfaces. ```APIDOC ## Configuration ### Description Details on how to configure and set up the tyme4go library. ### Setup - **Import and package setup**: Instructions for importing and setting up the package. - **Module initialization**: Notes that no explicit setup is required. ### Constants and Data - **Calendar constants and name arrays**: Access to constants and name arrays for calendars. - **Supported date ranges**: Information on the supported date ranges for each calendar. ### Extensibility and Guarantees - **Provider interfaces for extension**: How to extend the library using provider interfaces. - **Data-driven configuration approach**: Explanation of the configuration approach. - **Thread safety guarantees**: Information on thread safety. - **Performance characteristics**: Notes on performance. - **Error handling strategy**: Overview of the error handling strategy. - **Version compatibility**: Information on version compatibility. ``` -------------------------------- ### Example: Print Auspicious God Names Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Demonstrates fetching auspicious gods for a given month and day and printing their names. Includes basic error handling. ```go gods, err := tyme.God{}.GetDayGods(monthCycle, dayCycle) if err == nil { for _, god := range gods { fmt.Println(god.GetName()) } } ``` -------------------------------- ### Get Phenology from Index Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Creates a Phenology object from a given year and index. Retrieves the start date of the phenological period. ```go phenology := tyme.Phenology{}.FromIndex(2020, 15) startDate := phenology.GetSolarDay() ``` -------------------------------- ### Example: Calculate and Print FetusDay Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Demonstrates creating a FetusDay object from a specific lunar date and printing its representation. Requires importing the tyme package. ```go lunar, _ := tyme.LunarDay{}.FromYmd(1986, 4, 21) fetus := tyme.FetusDay{}.FromLunarDay(lunar) fmt.Println(fetus) ``` -------------------------------- ### SolarWeek.FromYm Constructor Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Creates a SolarWeek instance by specifying the year, month, week number, and the starting day of the week. ```APIDOC ## SolarWeek.FromYm Constructor ### Description Creates a SolarWeek instance by specifying the year, month, week number, and the starting day of the week. ### Method `SolarWeek.FromYm` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **year** (int) - Required - Calendar year - **month** (int) - Required - Month - **week** (int) - Required - Week number within month - **start** (int) - Required - Start day of week (1=Monday, 7=Sunday) ### Request Example None ### Response #### Success Response (200) - **SolarWeek** (*SolarWeek) - Pointer to the created SolarWeek instance or an error. #### Response Example None ``` -------------------------------- ### Get Day Recommends Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Retrieves a list of recommended activities (宜) for a specific day based on the month and day pillars. ```APIDOC ## GetDayRecommends ### Description Gets the recommended activities for a specific day. ### Method `func (Taboo) GetDayRecommends(month SixtyCycle, day SixtyCycle) ([]Taboo, error)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **month** (SixtyCycle) - Required - Month pillar - **day** (SixtyCycle) - Required - Day pillar ### Request Example ```go recommends, _ := tyme.Taboo{}.GetDayRecommends(monthCycle, dayCycle) fmt.Println("宜(Recommended):") for _, r := range recommends { fmt.Println(" " + r.GetName()) } ``` ### Response #### Success Response (200) - **[]Taboo, error** - A slice of Taboo objects representing recommended activities and an error if any occurred. ``` -------------------------------- ### Creating Dates from Year, Month, Day Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to create date objects for different calendar systems using year, month, and day components. Examples cover Lunar, Hijri, and Tibetan calendars. ```Go package main import ( "fmt" "github.com/6tail/tyme4go/solar" ) func main() { // Example: Creating a SolarDay sday := solar.NewSolarDay(2023, 10, 26) fmt.Println(sday.String()) } ``` ```Go package main import ( "fmt" "github.com/6tail/tyme4go/islamic" ) func main() { // Example: Creating a HijriDay hday := islamic.NewHijriDay(1445, 4, 11) fmt.Println(hday.String()) } ``` ```Go package main import ( "fmt" "github.com/6tail/tyme4go/tibetan" ) func main() { // Example: Creating a RabByungDay rday := tibetan.NewRabByungDay(2149, 8, 15) fmt.Println(rday.String()) } ``` -------------------------------- ### Iterate Through Dates Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md This snippet demonstrates how to iterate through a range of dates, starting from a given start date until an end date is reached. The `Next(1)` method advances the date by one day. ```go current := startDate for current.IsBefore(endDate) { processDate(current) current = current.Next(1) } ``` -------------------------------- ### SixtyCycle Name Parsing Error Examples Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/errors.md Shows examples of triggering unknown name errors when parsing SixtyCycle names. This occurs for invalid or incomplete name strings, or mismatched stem/branch combinations. ```go _, err := tyme.SixtyCycle{}.FromName("invalid") // Error: "unknown name: invalid" _, err = tyme.SixtyCycle{}.FromName("甲") // Error: (matches nothing, needs two chars) ``` -------------------------------- ### HijriYear Key Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/islamic-calendar.md Provides a method to get the total day count for a HijriYear. ```go func (o HijriYear) GetDayCount() int ``` -------------------------------- ### Get Recommended Activities for a Day Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Retrieves a list of recommended activities (宜) for a specific day, based on the month and day pillars. Returns a slice of Taboo objects and an error. ```go func (Taboo) GetDayRecommends(month SixtyCycle, day SixtyCycle) ([]Taboo, error) ``` -------------------------------- ### Iteration Over Date Ranges Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Shows how to iterate over a range of dates, which is useful for processing data over a period or generating reports. Examples cover iterating through days or months. ```Go package main import ( "fmt" "github.com/6tail/tyme4go/solar" ) func main() { // Iterate over a range of SolarDays startDay := solar.NewSolarDay(2023, 10, 25) endDay := solar.NewSolarDay(2023, 10, 28) currentDay := startDay for currentDay.Before(endDay) || currentDay.Equal(endDay) { fmt.Println(currentDay.String()) currentDay = currentDay.AddDays(1) } } ``` -------------------------------- ### Navigate SolarDay by Number of Days Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Use the `Next` method to get a new SolarDay offset by a specified number of days. Positive values advance the date, while negative values go back. ```go func (o SolarDay) Next(n int) SolarDay ``` -------------------------------- ### Get Utility Information for Lunar Day Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/lunar-calendar.md Accesses utility methods for lunar day components and string representation. Use these to get the lunar month, day of the week, lunar day name, or a full string representation. ```go func (o LunarDay) GetLunarMonth() LunarMonth func (o LunarDay) GetWeek() Week func (o LunarDay) GetName() string func (o LunarDay) String() string ``` -------------------------------- ### Create SixtyCycleHour from SolarTime Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Construct a SixtyCycleHour object from a given SolarTime. Traditional hours start from 23:00 of the previous day. ```go func (SixtyCycleHour) FromSolarTime(solarTime SolarTime) SixtyCycleHour ``` -------------------------------- ### Get Astronomical & Seasonal Data Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Retrieves astronomical and seasonal information for a SolarDay, such as solar terms, phenology, and moon phases. ```go func (o SolarDay) GetTerm() SolarTerm func (o SolarDay) GetTermDay() SolarTermDay func (o SolarDay) GetPhenology() Phenology func (o SolarDay) GetPhenologyDay() PhenologyDay func (o SolarDay) GetPhase() Phase func (o SolarDay) GetPhaseDay() PhaseDay ``` -------------------------------- ### Get SixtyCycle String Representation Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Utility methods for accessing the cycle information, including the full name, string representation, and index. ```go func (o SixtyCycle) GetName() string { // ... implementation details ... } func (o SixtyCycle) String() string { // ... implementation details ... } func (o SixtyCycle) GetIndex() int { // ... implementation details ... } ``` -------------------------------- ### Advance SolarTime by Seconds Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/time-representation.md Use the `Next` method to get a new SolarTime instance offset by a specified number of seconds. This can be used to add or subtract time. ```go time, _ := tyme.SolarTime{}.FromYmdHms(2020, 1, 1, 12, 0, 0) nextHour := time.Next(3600) // Add 1 hour nextDay := time.Next(86400) // Add 1 day previousDay := time.Next(-86400) // Subtract 1 day ``` -------------------------------- ### Get Tibetan Month and Day Components Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/tibetan-calendar.md Access utility methods to retrieve the Tibetan month associated with a day, its formatted name (including leap indicators), and its full string representation. These methods help in understanding the components and display format of a Tibetan day. ```go func (o RabByungDay) GetRabByungMonth() RabByungMonth func (o RabByungDay) GetName() string func (o RabByungDay) String() string ``` ```go day, _ := tyme.RabByungDay{}.FromYmd(1951, 6, 15) fmt.Println(day.GetName()) // 十五 or 闰十五 fmt.Println(day.String()) // Full representation with month ``` -------------------------------- ### Phenology Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Represents one of 72 five-day periods dividing the year by natural phenomena. It can be created from an index and provides methods to get the start date and traditional descriptions. ```APIDOC ## Phenology ### Description Represents one of 72 five-day periods dividing the year by natural phenomena. It is structured as 24 solar terms multiplied by 3 periods. ### Usage ```go phenology := tyme.Phenology{}.FromIndex(2020, 15) startDate := phenology.GetSolarDay() ``` ### Traditional Descriptions Each phenology has a traditional Chinese description of natural phenomena (e.g., "桃始华" = peach trees bloom, "候雁来" = geese arrive). ``` -------------------------------- ### Create SolarMonth Instance Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Constructor for creating a SolarMonth instance by providing the year and month. Returns a pointer to SolarMonth or an error. ```go func (SolarMonth) FromYm(year int, month int) (*SolarMonth, error) ``` -------------------------------- ### Get SolarTerm Information Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Provides methods to retrieve the SolarDay associated with a SolarTerm, check if it's a 'Qi' (节气), and get its index. ```go func (o SolarTerm) GetSolarDay() SolarDay ``` ```go func (o SolarTerm) IsQi() bool ``` ```go func (o SolarTerm) GetIndex() int ``` -------------------------------- ### Get Auspicious Gods for a Day Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Retrieves a list of auspicious gods (吉神宜趋) for a specific day, given the month and day pillars in SixtyCycle format. Handles potential errors during retrieval. ```go func (God) GetDayGods(month SixtyCycle, day SixtyCycle) ([]God, error) ``` -------------------------------- ### LunarDay Validation Error Example Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/errors.md Shows an example of an illegal lunar day error. This occurs when the day exceeds the number of days available in a specific lunar month. ```go _, err := tyme.LunarDay{}.FromYmd(1986, 4, 31) // Error: "illegal day 31 in 丙寅年四月" (only 30 days in this month) ``` -------------------------------- ### SolarTime Validation Error Examples Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/errors.md Demonstrates triggering illegal hour and solar day errors when creating a SolarTime. Invalid hour, minute, or second values, as well as invalid date components, will result in errors. ```go _, err := tyme.SolarTime{}.FromYmdHms(2020, 1, 1, 25, 0, 0) // Error: "illegal hour: 25" _, err = tyme.SolarTime{}.FromYmdHms(2020, 1, 32, 12, 0, 0) // Error: "illegal solar day: 2020-1-32" ``` -------------------------------- ### Converting Between Calendar Systems Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Illustrates how to convert dates between different calendar systems, such as Gregorian to Hijri and Gregorian to Tibetan. This is useful for applications requiring cross-calendar calculations. ```Go package main import ( "fmt" "github.com/6tail/tyme4go/islamic" "github.com/6tail/tyme4go/solar" ) func main() { // Convert SolarDay to HijriDay sday := solar.NewSolarDay(2023, 10, 26) hday := islamic.NewHijriDayFromSolarDay(sday) fmt.Printf("%s -> %s\n", sday.String(), hday.String()) } ``` ```Go package main import ( "fmt" "github.com/6tail/tyme4go/solar" "github.com/6tail/tyme4go/tibetan" ) func main() { // Convert SolarDay to RabByungDay sday := solar.NewSolarDay(2023, 10, 26) rday := tibetan.NewRabByungDayFromSolarDay(sday) fmt.Printf("%s -> %s\n", sday.String(), rday.String()) } ``` -------------------------------- ### SixtyCycleDay Constructor and Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Constructor and key methods for interacting with a day in the sexagenary cycle. ```APIDOC ## SixtyCycleDay ### Constructor: FromSolarDay - **Description**: Creates a `SixtyCycleDay` from a solar date. - **Method**: N/A (Constructor for a struct) - **Parameters**: - **solarDay** (SolarDay) - Required - The solar date to convert. - **Return Type**: `SixtyCycleDay` ### Key Methods #### GetSolarDay - **Description**: Returns the `SolarDay` associated with this sexagenary day. - **Method**: N/A (Method of a struct) - **Return Type**: `SolarDay` #### GetYear - **Description**: Returns the `SixtyCycle` year pillar for this sexagenary day. - **Method**: N/A (Method of a struct) - **Return Type**: `SixtyCycle` #### GetMonth - **Description**: Returns the `SixtyCycle` month pillar for this sexagenary day. - **Method**: N/A (Method of a struct) - **Return Type**: `SixtyCycle` #### GetSixtyCycle - **Description**: Returns the `SixtyCycle` day pillar for this sexagenary day. - **Method**: N/A (Method of a struct) - **Return Type**: `SixtyCycle` ### Divination Methods #### GetDuty - **Description**: Returns the divination `Duty` for the day. - **Method**: N/A (Method of a struct) - **Return Type**: `Duty` #### GetTwelveStar - **Description**: Returns the divination `TwelveStar` for the day. - **Method**: N/A (Method of a struct) - **Return Type**: `TwelveStar` #### GetGods - **Description**: Returns a list of divination `God`s for the day. - **Method**: N/A (Method of a struct) - **Return Type**: `[]God, error` #### GetRecommends - **Description**: Returns a list of recommended `Taboo`s for the day. - **Method**: N/A (Method of a struct) - **Return Type**: `[]Taboo, error` #### GetAvoids - **Description**: Returns a list of `Taboo`s to avoid for the day. - **Method**: N/A (Method of a struct) - **Return Type**: `[]Taboo, error` ``` -------------------------------- ### Get Moon Phase Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Retrieve the moon phase (月相) for a given solar date. ```go // Moon phase phase := solar.GetPhase() // 月相 ``` -------------------------------- ### Common Utility Methods for Cycle and Culture Types Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Illustrates common methods available on cycle and culture types, such as GetName, GetIndex, String, Next, and Equals. ```go func (o Type) GetName() string // Chinese name func (o Type) GetIndex() int // Position in cycle func (o Type) String() string // String representation func (o Type) Next(n int) Type // Navigate forward/backward func (o Type) Equals(target Type) bool // Equality check ``` -------------------------------- ### Get LoopTyme Name and Index Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Retrieves the Chinese name and the 0-based index of a LoopTyme instance. ```Go func (o LoopTyme) GetName() string func (o LoopTyme) GetIndex() int ``` -------------------------------- ### SolarMonth Constructor Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Creates a SolarMonth instance from a given year and month. ```APIDOC ## FromYm (*SolarMonth, error) ### Description Creates a SolarMonth instance from a specified year and month. ### Method Constructor ### Parameters #### Path Parameters - **year** (int) - Required - The calendar year. - **month** (int) - Required - The month of the year (1-12). ### Returns `*SolarMonth` - A pointer to the created SolarMonth object, or an error if the input is invalid. ``` -------------------------------- ### Get Nine Stars Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Retrieve the Nine Stars (九星) associated with a given solar date. ```go // Nine stars stars := solar.GetNineStar() // 九星 ``` -------------------------------- ### Create a Tibetan Month Instance Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/tibetan-calendar.md Use the `FromYm` constructor to create a `RabByungMonth` object by providing the Tibetan year and month. This is the primary way to instantiate and work with Tibetan months. ```go func (RabByungMonth) FromYm(year int, month int) (*RabByungMonth, error) ``` -------------------------------- ### Get Solar Term Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Retrieve the specific solar term (节气) for a given solar date. ```go // Solar term term := solar.GetTerm() // 节气 ``` -------------------------------- ### Direction Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Represents the 8 cardinal directions plus the center. It provides methods to get the name of the direction. ```APIDOC ## Direction — Cardinal Directions (方位) ### Description Represents 8 cardinal directions plus center. ### Possible Values - 中 (Center) - 东 (East) - 东南 (Southeast) - 南 (South) - 西南 (Southwest) - 西 (West) - 西北 (Northwest) - 北 (North) - 东北 (Northeast) ### Usage ```go direction := element.GetDirection() fmt.Println(direction.GetName()) // 东 ``` ``` -------------------------------- ### Get Festivals and Holidays Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Retrieve lunar festivals for a lunar date and legal holidays for a solar date. ```go // Festivals and holidays festival := lunar.GetFestival() holiday := solar.GetLegalHoliday() ``` -------------------------------- ### Create SolarDay from Year, Month, Day Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Use `FromYmd` to create a SolarDay instance. It validates the date and returns a pointer to SolarDay or an error if the date is invalid. Note that dates between October 5-14, 1582 are not allowed. ```go package main import ( "fmt" "github.com/6tail/tyme4go/tyme" ) func main() { solarDay, err := tyme.SolarDay{}.FromYmd(1986, 5, 29) if err != nil { fmt.Println("Error:", err) return } fmt.Println(solarDay) // 1986年5月29日 } ``` -------------------------------- ### SolarFestival.FromYmd Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Creates a SolarFestival instance from year, month, and day. ```APIDOC ## SolarFestival.FromYmd ### Description Creates a SolarFestival instance from year, month, and day. ### Usage ```go festival := tyme.SolarFestival{}.FromYmd(2020, 12, 25) if festival != nil { fmt.Println(festival.GetName()) // 圣诞节 } ``` ### Typical Festivals: - Valentine's Day (2月14日) - Mother's Day (various dates by country) - Father's Day (various dates by country) - Christmas (12月25日) - New Year (1月1日) ``` -------------------------------- ### Get Day Count of SolarYear Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Returns the total number of days in a SolarYear, which is 365 or 366 for leap years. ```go func (o SolarYear) GetDayCount() int ``` -------------------------------- ### Working with Time Representations Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Illustrates the use of different time representations, including SolarTime, LunarHour, and SixtyCycleHour. This covers standard time, traditional Chinese hours, and astronomical time calculations. ```Go package main import ( "fmt" "github.com/6tail/tyme4go/solar" "github.com/6tail/tyme4go/timeutil" ) func main() { // Create a SolarTime object time := timeutil.NewSolarTime(2023, 10, 26, 14, 30, 0) fmt.Printf("Solar Time: %s\n", time.String()) // Accessing Lunar Hour (requires a LunarDay) // lday := lunar.NewLunarDay(2023, 9, 12, false) // lhour := lday.Hour(14) // Example for 2 PM // fmt.Printf("Lunar Hour: %s\n", lhour.String()) } ``` -------------------------------- ### Get Cardinal Direction Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Retrieves the current cardinal direction. This is useful for applications involving spatial or directional calculations. ```go direction := element.GetDirection() fmt.Println(direction.GetName()) // 东 ``` -------------------------------- ### Get Phenology Period Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Retrieve the phenology period (候), one of the 72 periods, for a given solar date. ```go // Phenology (72 periods) phenology := solar.GetPhenology() // 候 ``` -------------------------------- ### SixtyCycleHour Constructor and Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Constructor and key methods for interacting with an hour in the sexagenary cycle. ```APIDOC ## SixtyCycleHour ### Constructor: FromSolarTime - **Description**: Creates a `SixtyCycleHour` from a solar date/time. - **Method**: N/A (Constructor for a struct) - **Parameters**: - **solarTime** (SolarTime) - Required - The solar date/time to convert. - **Return Type**: `SixtyCycleHour` ### Key Methods #### GetSixtyCycle - **Description**: Returns the `SixtyCycle` representation for this hour. - **Method**: N/A (Method of a struct) - **Return Type**: `SixtyCycle` #### Next - **Description**: Returns a `SixtyCycleHour` offset by `n` two-hour periods. - **Method**: N/A (Method of a struct) - **Parameters**: - **n** (int) - Required - The number of two-hour periods to offset. ``` -------------------------------- ### God Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/types.md Represents beneficial deities and forces in divination. It can be created from an index and provides a method to get the gods for a specific day. ```APIDOC ## God ### Description Represents beneficial deities and forces in divination. ### Methods - `FromIndex(index int) God`: Create from index. - `GetDayGods(month SixtyCycle, day SixtyCycle) ([]God, error)`: Get gods for a specific day. ``` -------------------------------- ### Compare SolarTimes Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/time-representation.md Use `IsBefore` and `IsAfter` methods to compare two SolarTime instances. These methods return a boolean indicating the temporal relationship. ```go func (o SolarTime) IsBefore(target SolarTime) bool func (o SolarTime) IsAfter(target SolarTime) bool ``` -------------------------------- ### Get Day Count of SolarMonth Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Returns the number of days in a given SolarMonth, accounting for month length and leap years. ```go func (o SolarMonth) GetDayCount() int ``` -------------------------------- ### Handle Date Creation Errors Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/configuration.md Demonstrates how to handle potential validation errors when creating date objects using the standard Go error pattern. ```go value, err := tyme.SolarDay{}.FromYmd(1986, 5, 29) if err != nil { // Handle validation error log.Fatal(err) } ``` -------------------------------- ### Accessing Calendar Properties Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to access various properties of calendar dates, such as the day of the week, month name, or year. This is useful for displaying date information. ```Go package main import ( "fmt" "github.com/6tail/tyme4go/solar" ) func main() { // Access properties of a SolarDay sday := solar.NewSolarDay(2023, 10, 26) fmt.Printf("Year: %d\n", sday.Year()) fmt.Printf("Month: %d\n", sday.Month()) fmt.Printf("Day: %d\n", sday.Day()) fmt.Printf("Day of Week: %s\n", sday.Weekday().String()) } ``` -------------------------------- ### Get LunarYear Properties Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/lunar-calendar.md Retrieves key properties of a LunarYear, including the total number of days and whether it is a leap year. ```go func (o LunarYear) GetDayCount() int func (o LunarYear) IsLeapYear() bool ``` -------------------------------- ### Get Day Avoids Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Retrieves a list of taboo activities (忌) for a specific day based on the month and day pillars. ```APIDOC ## GetDayAvoids ### Description Gets the taboo activities for a specific day. ### Method `func (Taboo) GetDayAvoids(month SixtyCycle, day SixtyCycle) ([]Taboo, error)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **month** (SixtyCycle) - Required - Month pillar - **day** (SixtyCycle) - Required - Day pillar ### Request Example ```go avoids, _ := tyme.Taboo{}.GetDayAvoids(monthCycle, dayCycle) fmt.Println("忌(Avoid):") for _, a := range avoids { fmt.Println(" " + a.GetName()) } ``` ### Response #### Success Response (200) - **[]Taboo, error** - A slice of Taboo objects representing taboo activities and an error if any occurred. ``` -------------------------------- ### Create LoopTyme from Index Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Creates a LoopTyme instance using an index and a slice of names. The index wraps using modulo arithmetic. ```Go func (LoopTyme) FromIndex(names []string, index int) *LoopTyme ``` -------------------------------- ### Get Day Gods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/divination-system.md Retrieves a list of auspicious gods (吉神宜趋) for a specific day based on the month and day pillars. ```APIDOC ## GetDayGods ### Description Gets the list of auspicious gods for a specific day. ### Method `func (God) GetDayGods(month SixtyCycle, day SixtyCycle) ([]God, error)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **month** (SixtyCycle) - Required - Month pillar - **day** (SixtyCycle) - Required - Day pillar ### Request Example ```go gods, err := tyme.God{}.GetDayGods(monthCycle, dayCycle) if err == nil { for _, god := range gods { fmt.Println(god.GetName()) } } ``` ### Response #### Success Response (200) - **[]God, error** - A slice of God objects and an error if any occurred. ``` -------------------------------- ### SolarTerm Key Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Provides access to key information and properties of a SolarTerm instance. ```APIDOC ## SolarTerm Key Methods ### Description Provides access to key information and properties of a SolarTerm instance, including the associated SolarDay, whether it's a 'Qi' term, and its index. ### Methods #### GetSolarDay - **Description**: Retrieves the SolarDay associated with the SolarTerm. - **Return Type**: SolarDay #### IsQi - **Description**: Checks if the SolarTerm is a 'Qi' (节气) term. - **Return Type**: bool #### GetIndex - **Description**: Retrieves the index of the SolarTerm. - **Return Type**: int ``` -------------------------------- ### LegalHoliday.FromYmd Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Creates a LegalHoliday instance from year, month, and day. ```APIDOC ## LegalHoliday.FromYmd ### Description Creates a LegalHoliday instance from year, month, and day. ### Usage ```go holiday := tyme.LegalHoliday{}.FromYmd(2020, 1, 1) if holiday != nil { fmt.Println(holiday.GetName()) // 元旦节 } ``` ### Supported Holidays Include: - 元旦节 (New Year's Day) - 春节 (Spring Festival/Chinese New Year) - 清明节 (Qingming Festival) - 劳动节 (Labour Day) - 端午节 (Dragon Boat Festival) - 中秋节 (Mid-Autumn Festival) - 国庆节 (National Day) ``` -------------------------------- ### Get Holidays & Festivals Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Retrieves holiday and festival information for a SolarDay. Returns nil for legal holidays or festivals if none are applicable. ```go func (o SolarDay) GetLegalHoliday() *LegalHoliday func (o SolarDay) GetFestival() *SolarFestival ``` -------------------------------- ### Get NineDay Information Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Retrieves the current NineDay period and its index. This helps in tracking the progression of the winter 'counting nine' period. ```go nineDay := solar.GetNineDay() if nineDay != nil { period := nineDay.GetNine().GetName() // 一九, 二九, ... 九九 dayIndex := nineDay.GetDayIndex() } ``` -------------------------------- ### Import Tyme4go Package Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/configuration.md Import the main tyme4go package to access its public APIs. ```go import ( "github.com/6tail/tyme4go/tyme" ) ``` -------------------------------- ### Create LunarMonth Instance Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/lunar-calendar.md Creates a LunarMonth instance from a given lunar year and month. The month parameter accepts values from 1-13, with negative values indicating a leap month. ```go func (LunarMonth) FromYm(year int, month int) (*LunarMonth, error) ``` -------------------------------- ### Get LunarMonth Properties Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/lunar-calendar.md Retrieves key properties of a LunarMonth, such as the total number of days in the month and the Julian day of its first day. ```go func (o LunarMonth) GetDayCount() int func (o LunarMonth) GetFirstJulianDay() JulianDay ``` -------------------------------- ### Compare SolarDay Dates Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Use `IsBefore`, `IsAfter`, and `Equals` methods to compare this SolarDay with another. These methods return a boolean indicating the relationship between the two dates. ```go func (o SolarDay) IsBefore(target SolarDay) bool func (o SolarDay) IsAfter(target SolarDay) bool func (o SolarDay) Equals(target SolarDay) bool ``` -------------------------------- ### Get Divination Information from Lunar Date Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Retrieve divination-related information such as Gods, auspicious recommendations, and taboos for a given lunar date. ```go // Auspicious/inauspicious for a day gods, _ := lunar.GetGods() recommends, _ := lunar.GetRecommends() avoids, _ := lunar.GetAvoids() ``` -------------------------------- ### Utility Methods for SolarDay Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/solar-calendar.md Provides utility methods for accessing components of a SolarDay, such as its month, Julian day, index in the year, and string representation. ```go func (o SolarDay) GetSolarMonth() SolarMonth func (o SolarDay) GetJulianDay() JulianDay func (o SolarDay) GetIndexInYear() int func (o SolarDay) GetName() string func (o SolarDay) String() string ``` -------------------------------- ### Get HijriMonth from Year and Month Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/islamic-calendar.md Creates a HijriMonth instance for the specified Islamic year and month. Returns an error if the month is invalid. ```go func (HijriMonth) FromYm(year int, month int) (*HijriMonth, error) ``` -------------------------------- ### Create SolarTime from Year, Month, Day, Hour, Minute, Second Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/time-representation.md Use `FromYmdHms` to create a SolarTime instance. It returns a pointer to SolarTime or an error if the date or time components are invalid. ```go package main import ( "fmt" "github.com/6tail/tyme4go/tyme" ) func main() { solarTime, err := tyme.SolarTime{}.FromYmdHms(1986, 5, 29, 14, 30, 0) if err != nil { fmt.Println("Error:", err) return } fmt.Println(solarTime) // 1986年5月29日 14:30:00 } ``` -------------------------------- ### Compare SixtyCycle Instances Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Checks for equality between two SixtyCycle instances. ```go func (o SixtyCycle) Equals(target SixtyCycle) bool { // ... implementation details ... } ``` -------------------------------- ### Get Day Index within Hijri Year Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/islamic-calendar.md Returns the day index (0-based) within the Islamic year for a given HijriDay. ```go hijri, _ := tyme.HijriDay{}.FromYmd(1406, 6, 15) index := hijri.GetIndexInYear() ``` -------------------------------- ### LunarMonth Key Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/lunar-calendar.md Key methods for interacting with a LunarMonth object. ```APIDOC ## GetDayCount ### Description Retrieves the total number of days in the lunar month. ### Method `GetDayCount()` ### Returns `int` ## GetFirstJulianDay ### Description Retrieves the Julian day number for the first day of the lunar month. ### Method `GetFirstJulianDay()` ### Returns `JulianDay` ``` -------------------------------- ### Get DogDay Information Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Retrieves the current DogDay period and its index within the season. This is useful for identifying specific summer heat periods. ```go dogDay := solar.GetDogDay() if dogDay != nil { period := dogDay.GetDog().GetName() // 初伏, 中伏, or 末伏 dayIndex := dogDay.GetDayIndex() } ``` -------------------------------- ### Create LegalHoliday Instance Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Creates a LegalHoliday instance for a specific date. This is used for official legal holidays. ```Go holiday := tyme.LegalHoliday{}.FromYmd(2020, 1, 1) if holiday != nil { fmt.Println(holiday.GetName()) // 元旦节 } ``` -------------------------------- ### SixtyCycleMonth Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Retrieve the SixtyCycle representation for the month or the next month in the cycle. ```go func (o SixtyCycleMonth) GetSixtyCycle() SixtyCycle func (o SixtyCycleMonth) GetSixtyCycleYear() SixtyCycleYear func (o SixtyCycleMonth) Next(n int) SixtyCycleMonth ``` -------------------------------- ### Utility Methods Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Common methods implemented by most cycle and culture types, including GetName, GetIndex, String, Next, and Equals. ```APIDOC ## Utility Methods (Common Pattern) Most cycle and culture types implement these common methods: ```go func (o Type) GetName() string // Chinese name func (o Type) GetIndex() int // Position in cycle func (o Type) String() string // String representation func (o Type) Next(n int) Type // Navigate forward/backward func (o Type) Equals(target Type) bool // Equality check ``` ``` -------------------------------- ### Create Solar Date with Time Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/README.md Create a Gregorian solar date object with specific time components (hour, minute, second). ```go // With time solarTime, err := tyme.SolarTime{}.FromYmdHms(1986, 5, 29, 14, 30, 0) ``` -------------------------------- ### Error Handling Patterns Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Illustrates common error handling patterns when working with the tyme4go library, including validation errors and special nil return cases. This helps in writing robust applications. ```Go package main import ( "fmt" "github.com/6tail/tyme4go/solar" ) func main() { // Example of invalid date creation // This might return an error or a special value depending on implementation // For demonstration, assume a function that returns an error for invalid input // invalidDay, err := solar.NewSolarDayWithError(2023, 13, 1) // if err != nil { // fmt.Printf("Error creating date: %v\n", err) // } // Example of checking for nil return values for specific divination results // (Specific example depends on the divination function) fmt.Println("Error handling examples would be shown here.") } ``` -------------------------------- ### Phenology Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/types.md Represents one of the 72 phenological periods (候), indicating natural phenomena related to seasons. It can be created from an index and provides the start date of the period. ```APIDOC ## Phenology ### Description Represents one of the 72 phenological periods (春秋冬夏各18候). ### Methods - `FromIndex(year int, index int) Phenology`: Create phenology period. - `GetSolarDay() SolarDay`: Get start date of period. - `Next(n int) Phenology`: Get next/previous period. ``` -------------------------------- ### LunarMonth Constructor Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/lunar-calendar.md Creates a LunarMonth instance from year and month. ```APIDOC ## FromYm ### Description Creates a LunarMonth instance. ### Constructor `func (LunarMonth) FromYm(year int, month int) (*LunarMonth, error)` ### Parameters #### Path Parameters - **year** (int) - Required - Lunar year - **month** (int) - Required - Month (1-13, negative for leap month) ### Returns `*LunarMonth` pointer or error ``` -------------------------------- ### SolarTime.IsBefore and SolarTime.IsAfter Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/time-representation.md Compares this SolarTime instance with another SolarTime instance to determine chronological order. ```APIDOC ## SolarTime Time Comparison ### Description Compares this SolarTime with another SolarTime. ### Methods - **IsBefore(target SolarTime) bool**: Returns true if this time is strictly before the target time. - **IsAfter(target SolarTime) bool**: Returns true if this time is strictly after the target time. ### Parameters #### Path Parameters - **target** (SolarTime) - Yes - The SolarTime instance to compare against. ### Response #### Success Response - **bool**: `true` if the condition (before or after) is met, `false` otherwise. ``` -------------------------------- ### SolarTerm Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/types.md Represents one of the 24 solar terms marking seasonal transitions in the solar calendar. It can be created from an index and provides the start date and index of the term. ```APIDOC ## SolarTerm ### Description One of the 24 solar terms marking seasonal transitions in the solar calendar. ### Possible Values 冬至 大寒 立春 雨水 惊蛰 春分 清明 谷雨 立夏 小满 芒种 夏至 小暑 大暑 立秋 处暑 白露 秋分 寒露 霜降 立冬 小雪 大雪 (indices 0-23) ### Methods - `FromIndex(year int, index int) SolarTerm`: Create solar term. - `GetSolarDay() SolarDay`: Get when this term starts. - `GetIndex() int`: Get term index (0-23). - `IsQi() bool`: True if this is a major solar term (odd index). - `GetYear() int`: Get year. ``` -------------------------------- ### PlumRainDay Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Represents the early summer rainy season known as Plum Rain Season. It defines the start and end boundaries based on specific calendar days. ```APIDOC ## PlumRainDay — Plum Rain Season (梅雨) ### Description Represents the early summer rainy season. ### Boundaries - Start: 1st Bing day after Grain in Ear (芒种) - End: 1st Wei day after Minor Heat (小暑) ### Usage ```go plumRain := solar.GetPlumRainDay() if plumRain != nil { inMeiyuSeason := true } ``` ``` -------------------------------- ### Utilities and Helpers Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/COMPLETION_SUMMARY.txt Provides documentation for utility types and helper functions, including base types, festivals, special periods, and unit types. ```APIDOC ## Utilities and Helpers ### Description Utility types and helper functions for various calendar and time-related operations. ### Types - **LoopTyme**: Base type for cyclical elements. - **LegalHoliday, SolarFestival, LunarFestival**: Types for different kinds of holidays and festivals. - **SolarTerm and Phenology**: Documentation for solar terms and phenology. - **Special periods**: Includes DogDay, NineDay, PlumRainDay. - **Direction and positional types**: Types related to direction and position. - **Base type hierarchy**: Documentation on the hierarchy of base types. - **Unit types**: Year, Month, Day, Second. ### Examples - Working with different unit types. - Accessing information on special periods. ``` -------------------------------- ### Create SixtyCycle from Index Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/sexagenary-cycle.md Creates a SixtyCycle from its position in the 60-year cycle. The index ranges from 0 (甲子) to 59 (癸亥). ```go package main import ( "fmt" "github.com/6tail/tyme4go/tyme" ) func main() { cycle := tyme.SixtyCycle{}.FromIndex(0) // 甲子 fmt.Println(cycle) // 甲子 } ``` -------------------------------- ### Get JulianDay Properties Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/time-representation.md These methods retrieve specific properties from a JulianDay object. GetDay returns the Julian day number as a float64, and GetWeek returns the day of the week. ```go func (o JulianDay) GetDay() float64 func (o JulianDay) GetWeek() Week ``` -------------------------------- ### Create SolarTerm Instance Source: https://github.com/6tail/tyme4go/blob/master/_autodocs/api-reference/utilities-helpers.md Creates a SolarTerm instance for a specific year and solar term index. The SolarTerm represents one of the 24 seasonal transitions. ```Go term := tyme.SolarTerm{}.FromIndex(2020, 3) // Spring Equinox (春分) startDate := term.GetSolarDay() ```