### Add Tyme Dependency and Basic Usage Source: https://pub.dev/documentation/tyme/latest/index.html Demonstrates how to add the Tyme library to your project dependencies and provides a basic example of creating and printing SolarDay objects, including their corresponding Lunar, Tibetan, and Hijri dates. ```yaml dependencies: tyme4dart: ^1.5.0 ``` ```dart import 'package:tyme/tyme.dart'; void main() { // 公历 SolarDay solarDay = SolarDay.fromYmd(1986, 5, 29); // 1986年5月29日 print(solarDay); // 农历丙寅年四月廿一 print(solarDay.getLunarDay()); // 第十七饶迥火虎年四月廿一 print(solarDay.getRabByungDay()); // 1406年赖买丹月20日 print(solarDay.getHijriDay()); } ``` -------------------------------- ### getSolarDays Source: https://pub.dev/documentation/tyme/latest/tyme/ThreePillars/getSolarDays.html Lists SolarDay objects for a given range of years. The range is inclusive of both start and end years. ```APIDOC ## getSolarDays ### Description Retrieves a list of SolarDay objects for a specified range of years (inclusive). ### Method Signature List getSolarDays(int startYear, int endYear) ### Parameters #### Path Parameters - **startYear** (int) - Required - The starting year of the range (inclusive). - **endYear** (int) - Required - The ending year of the range (inclusive). ### Notes Supports years from 1 to 9999. ``` -------------------------------- ### getSolarDays Method Implementation Source: https://pub.dev/documentation/tyme/latest/tyme/ThreePillars/getSolarDays.html This method calculates a list of SolarDay objects between a start and end year. It requires careful handling of celestial stem and branch calculations, and solar term offsets to ensure accuracy. The method returns an empty list if initial conditions are not met. ```java List getSolarDays(int startYear, int endYear) { List l = []; // 月地支距寅月的偏移值 int m = month.getEarthBranch().next(-2).getIndex(); // 月天干要一致 if (HeavenStem.fromIndex((year.getHeavenStem().getIndex() + 1) * 2 + m) != month.getHeavenStem()) { return l; } // 1年的立春是辛酉,序号57 int y = year.next(-57).getIndex() + 1; // 节令偏移值 m *= 2; int baseYear = startYear - 1; if (baseYear > y) { y += 60 * (((baseYear - y) / 60.0).ceil()); } while (y <= endYear) { // 立春为寅月的开始 SolarTerm term = SolarTerm.fromIndex(y, 3); // 节令推移,年干支和月干支就都匹配上了 if (m > 0) { term = term.next(m); } SolarDay solarDay = term.getSolarDay(); if (solarDay.getYear() >= startYear) { // 日干支和节令干支的偏移值 int d = day.next(-solarDay.getLunarDay().getSixtyCycle().getIndex()).getIndex(); if (d > 0) { // 从节令推移天数 solarDay = solarDay.next(d); } // 验证一下 if (solarDay.getSixtyCycleDay().getThreePillars() == this) { l.add(solarDay); } } y += 60; } return l; } ``` -------------------------------- ### Phase constructor Source: https://pub.dev/documentation/tyme/latest/tyme/Phase/Phase.html Initializes a new Phase object with the specified lunar year, lunar month, and index. ```APIDOC ## Phase constructor ### Description Initializes a new Phase object with the specified lunar year, lunar month, and index. ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Method - None (Constructor) ### Endpoint - None (Constructor) ### Request Example ```dart // Example of calling the constructor (syntax may vary based on SDK) var phase = Phase(2023, 10, 5); ``` ### Response #### Success Response - None (Constructor) #### Response Example - None (Constructor) ``` -------------------------------- ### Phase Constructor Implementation Source: https://pub.dev/documentation/tyme/latest/tyme/Phase/Phase.html Initializes a Phase object using lunar year, lunar month, and an index. It calculates the correct lunar month based on the provided year and index. ```java Phase(int lunarYear, int lunarMonth, int index) : super(names, index) { LunarMonth m = LunarMonth.fromYm(lunarYear, lunarMonth).next(index ~/ getSize()); this.lunarYear = m.getYear(); this.lunarMonth = m.getMonthWithLeap(); } ``` -------------------------------- ### FetusDay Constructor Implementation Source: https://pub.dev/documentation/tyme/latest/tyme/FetusDay/FetusDay.html Initializes FetusDay with a SixtyCycle, calculating fetusHeavenStem, fetusEarthBranch, side, and direction based on the SixtyCycle's index. ```dart FetusDay(SixtyCycle sixtyCycle) : fetusHeavenStem = FetusHeavenStem(sixtyCycle.getHeavenStem().index % 5), fetusEarthBranch = FetusEarthBranch(sixtyCycle.getEarthBranch().index % 6) { int index = [3, 3, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, -9, -9, -9, -9, -9, -5, -5, -1, -1, -1, -3, -7, -7, -7, -7, -5, 7, 7, 7, 7, 7, 7, 2, 2, 2, 2, 2, 3, 3, 3, 3][sixtyCycle.index]; side = Side.fromCode(index < 0 ? 0 : 1)!; direction = Direction(index); } ``` -------------------------------- ### FetusDay Constructor Source: https://pub.dev/documentation/tyme/latest/tyme/FetusDay/FetusDay.html Initializes a new FetusDay object with a SixtyCycle object. ```APIDOC ## FetusDay(SixtyCycle sixtyCycle) ### Description Initializes a new FetusDay object using a provided SixtyCycle object. The constructor calculates internal states like `fetusHeavenStem`, `fetusEarthBranch`, `side`, and `direction` based on the input `sixtyCycle`. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **sixtyCycle** (SixtyCycle) - Required - An object containing cycle data used to initialize the FetusDay. ### Implementation Details The constructor initializes `fetusHeavenStem` and `fetusEarthBranch` based on indices derived from `sixtyCycle`. It then determines `side` and `direction` based on a lookup table indexed by `sixtyCycle.index`. ``` -------------------------------- ### LunarFestival fromYmd Static Method Implementation Source: https://pub.dev/documentation/tyme/latest/tyme/LunarFestival/fromYmd.html This method constructs a LunarFestival object by parsing year, month, and day. It iterates through a list of names and associated data to identify specific lunar or solar events that match the provided date. It handles both direct date matches and date offsets relative to the current year. ```dart static LunarFestival? fromYmd(int year, int month, int day) { LunarDay d = LunarDay(year, month, day); for (int i = 0, j = names.length; i < j; i++) { int start = i * 8; Event e = Event(names[i], '@${data.substring(start, start + 8)}'); switch (e.getType()) { case EventType.LUNAR_DAY: int offset = e.getValue(5); if (offset == 0) { if (d.month == e.getValue(2) && d.day == e.getValue(3)) { return LunarFestival(i, e, d); } } else { List m = e.getMonth(d.year); LunarDay next = d.next(-offset); if (next.year == m[0] && next.month == m[1] && next.day == e.getValue(3)) { return LunarFestival(i, e, d); } } break; case EventType.TERM_DAY: final term = d.getSolarDay().getTermDay(); if (term.dayIndex == 0 && term.getSolarTerm().index == e.getValue(2) % 24) { return LunarFestival(i, e, d); } break; default: } } return null; } ``` -------------------------------- ### LunarDay Static Methods Source: https://pub.dev/documentation/tyme/latest/tyme/LunarDay-class.html Static methods available on the LunarDay class for utility purposes. ```APIDOC ## Static Methods ### validate(int year, int month, int day) → void * **Description**: Validates the provided year, month, and day for a lunisolar calendar date. * **Parameters**: * `year` (int) - The lunisolar year to validate. * `month` (int) - The lunisolar month to validate. * `day` (int) - The lunisolar day to validate. * **Returns**: void ``` -------------------------------- ### LunarFestival.fromYmd Source: https://pub.dev/documentation/tyme/latest/tyme/LunarFestival/fromYmd.html Creates a LunarFestival object from a given year, month, and day. It iterates through predefined events to find a matching lunar festival or solar term. ```APIDOC ## LunarFestival.fromYmd ### Description Creates a LunarFestival object from a given year, month, and day. It iterates through predefined events to find a matching lunar festival or solar term. ### Method static ### Signature LunarFestival? fromYmd(int year, int month, int day) ### Parameters - **year** (int) - The year. - **month** (int) - The month. - **day** (int) - The day. ### Returns - LunarFestival? - A LunarFestival object if a match is found, otherwise null. ``` -------------------------------- ### LunarDay Constructors Source: https://pub.dev/documentation/tyme/latest/tyme/LunarDay-class.html Constructors for creating LunarDay objects. You can initialize a LunarDay with year, month, and day, or use a static factory method for the same purpose. ```APIDOC ## Constructors ### LunarDay(int year, int month, int day) * **Description**: Initializes a LunarDay using the Chinese lunisolar year, month (negative for leap months), and day. * **Parameters**: * `year` (int) - The lunisolar year. * `month` (int) - The lunisolar month. Use a negative value for leap months. * `day` (int) - The lunisolar day. ### LunarDay.fromYmd(int year, int month, int day) * **Description**: Initializes a LunarDay using the Chinese lunisolar year, month (negative for leap months), and day. This is a static factory method. * **Parameters**: * `year` (int) - The lunisolar year. * `month` (int) - The lunisolar month. Use a negative value for leap months. * `day` (int) - The lunisolar day. ``` -------------------------------- ### validate static method Source: https://pub.dev/documentation/tyme/latest/tyme/HijriMonth/validate.html Validates if the provided year and month are within the acceptable range for a Hijri month. ```APIDOC ## validate static method ### Description Validates if the provided year and month are within the acceptable range for a Hijri month. ### Method Signature `void validate(int year, int month)` ### Parameters #### Path Parameters - **year** (int) - Required - The Hijri year to validate. - **month** (int) - Required - The Hijri month to validate. ### Implementation Details This method internally calls `AbstractCulture.validateRange` for the month and `HijriYear.validate` for the year. ``` -------------------------------- ### Validate Hijri Month and Year Source: https://pub.dev/documentation/tyme/latest/tyme/HijriMonth/validate.html Use this method to ensure that a given month (1-12) and year are valid for the Hijri calendar. It relies on `AbstractCulture.validateRange` and `HijriYear.validate` for range checking. ```java static void validate(int year, int month) { AbstractCulture.validateRange(month, 1, 12, 'hijri month'); HijriYear.validate(year); } ``` -------------------------------- ### LunarDay Constants Source: https://pub.dev/documentation/tyme/latest/tyme/LunarDay-class.html Constants defined within the LunarDay class. ```APIDOC ## Constants ### names → const List * **Description**: A constant list of names associated with the LunarDay class. * **Type**: const List ``` -------------------------------- ### LunarDay Methods Source: https://pub.dev/documentation/tyme/latest/tyme/LunarDay-class.html Methods available on the LunarDay class to retrieve specific lunisolar calendar information, such as festivals, taboo days, and celestial bodies. ```APIDOC ## Methods ### getAvoids() → List * **Description**: Returns a list of taboo activities for the day. * **Returns**: List ### getCompareIndex() → int * **Description**: Returns an index used for comparing LunarDay objects. * **Returns**: int * **Inherited**: Yes ### getDay() → int * **Description**: Returns the day of the month. * **Returns**: int * **Inherited**: Yes ### getDuty() → Duty * **Description**: Returns the 'Twelve Value Gods' (十二值神) for the day. * **Returns**: Duty ### getFestival() → LunarFestival? * **Description**: Returns the traditional lunisolar festival for the day, if any. * **Returns**: LunarFestival? (nullable) ### getFetusDay() → FetusDay * **Description**: Returns the 'Fetus Day' (胎神) information for the day. * **Returns**: FetusDay ### getGods() → List * **Description**: Returns a list of auspicious and inauspicious gods associated with the day. * **Returns**: List ### getHours() → List * **Description**: Returns a list of lunisolar hours for the day. * **Returns**: List ### getJupiterDirection() → Direction * **Description**: Returns the direction of Jupiter (太岁) for the day. * **Returns**: Direction ### getLunarMonth() → LunarMonth * **Description**: Returns the LunarMonth object representing the current lunisolar month. * **Returns**: LunarMonth ### getMinorRen() → MinorRen * **Description**: Returns the 'Minor Six Rens' (小六壬) divination for the day. * **Returns**: MinorRen ### getMonth() → int * **Description**: Returns the month of the year. * **Returns**: int * **Inherited**: Yes ### getName() → String * **Description**: Returns the name or representation of the LunarDay. * **Returns**: String * **Override**: Yes ### getNineStar() → NineStar * **Description**: Returns the 'Nine Stars' (九星) for the day. * **Returns**: NineStar ### getPhase() → Phase * **Description**: Returns the moon phase for the day. * **Returns**: Phase ### getPhaseDay() → PhaseDay * **Description**: Returns the day number within the current moon phase. * **Returns**: PhaseDay ### getRecommends() → List * **Description**: Returns a list of recommended activities for the day. * **Returns**: List ### getSixStar() → SixStar * **Description**: Returns the 'Six Stars' (六曜) for the day. * **Returns**: SixStar ### getSixtyCycle() → SixtyCycle * **Description**: Returns the Heavenly Stems and Earthly Branches (干支) for the day. * **Returns**: SixtyCycle ### getSixtyCycleDay() → SixtyCycleDay * **Description**: Returns the Heavenly Stems and Earthly Branches (干支) specifically for the day. * **Returns**: SixtyCycleDay ### getSolarDay() → SolarDay * **Description**: Returns the corresponding Gregorian SolarDay object. * **Returns**: SolarDay ### getThreePillars() → ThreePillars * **Description**: Returns the 'Three Pillars' (三柱) information (Year, Month, Day Pillars) for the day. * **Returns**: ThreePillars ### getTwelveStar() → TwelveStar * **Description**: Returns the 'Twelve Stars' (黄道黑道十二神) for the day. * **Returns**: TwelveStar ### getTwentyEightStar() → TwentyEightStar * **Description**: Returns the 'Twenty-Eight Mansions' (二十八宿) for the day. * **Returns**: TwentyEightStar ### getWeek() → Week * **Description**: Returns the day of the week (e.g., Monday, Tuesday). * **Returns**: Week ### getYear() → int * **Description**: Returns the year of the lunisolar calendar. * **Returns**: int * **Inherited**: Yes ### indexOfSize(int index, int size) → int * **Description**: Converts an index to be within the bounds of a given size. * **Parameters**: * `index` (int) - The index to convert. * `size` (int) - The maximum size. * **Returns**: int * **Inherited**: Yes ### isAfter(LunarDay target) → bool * **Description**: Checks if this LunarDay is after the specified target LunarDay. * **Parameters**: * `target` (LunarDay) - The target LunarDay to compare against. * **Returns**: bool ### isBefore(LunarDay target) → bool * **Description**: Checks if this LunarDay is before the specified target LunarDay. * **Parameters**: * `target` (LunarDay) - The target LunarDay to compare against. * **Returns**: bool ### next(int n) → LunarDay * **Description**: Advances or reverses the LunarDay by `n` steps. Positive `n` moves forward, negative `n` moves backward. * **Parameters**: * `n` (int) - The number of steps to advance or reverse. * **Returns**: LunarDay * **Override**: Yes ### noSuchMethod(Invocation invocation) → dynamic * **Description**: Invoked when a nonexistent method or property is accessed. * **Parameters**: * `invocation` (Invocation) - The invocation details. * **Returns**: dynamic * **Inherited**: Yes ### toString() → String * **Description**: Returns a string representation of the LunarDay object. * **Returns**: String * **Override**: Yes ``` -------------------------------- ### PengZuHeavenStem Property Implementation Source: https://pub.dev/documentation/tyme/latest/tyme/PengZu/pengZuHeavenStem.html Declare the PengZuHeavenStem property as a late final variable. ```dart late final PengZuHeavenStem pengZuHeavenStem; ``` -------------------------------- ### LunarDay Operators Source: https://pub.dev/documentation/tyme/latest/tyme/LunarDay-class.html Operators available for LunarDay objects, primarily for equality comparison. ```APIDOC ## Operators ### operator ==(Object other) → bool * **Description**: The equality operator. Checks if this LunarDay is equal to another object. * **Parameters**: * `other` (Object) - The object to compare with. * **Returns**: bool * **Inherited**: Yes ``` -------------------------------- ### LunarDay Properties Source: https://pub.dev/documentation/tyme/latest/tyme/LunarDay-class.html Properties of the LunarDay class that provide access to its components like day, month, and year. ```APIDOC ## Properties ### day → int * **Description**: The day of the month in the lunisolar calendar. * **Type**: int * **Inherited**: Yes ### hashCode → int * **Description**: The hash code for this object. * **Type**: int * **Inherited**: Yes * **Setter**: No ### month → int * **Description**: The month of the year in the lunisolar calendar. * **Type**: int * **Inherited**: Yes ### runtimeType → Type * **Description**: A representation of the runtime type of the object. * **Type**: Type * **Inherited**: Yes * **Setter**: No ### year → int * **Description**: The year in the lunisolar calendar. * **Type**: int * **Inherited**: Yes ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.