StemBranch.hour constructor

StemBranch.hour(
  1. LunarDateTime date,
  2. int index
)

Creates a StemBranch instance based on the given LunarDateTime date and index in range [0-11].

Implementation

factory StemBranch.hour(LunarDateTime date, int index) {
  final stemsOrdered = [
    Stem.yangWood,
    Stem.yinWood,
    Stem.yangFire,
    Stem.yinFire,
    Stem.yangEarth,
    Stem.yinEarth,
    Stem.yangMetal,
    Stem.yinMetal,
    Stem.yangWater,
    Stem.yinWater,
  ];
  final branchesOrdered = [
    Branch.rat,
    Branch.ox,
    Branch.tiger,
    Branch.rabbit,
    Branch.dragon,
    Branch.snake,
    Branch.horse,
    Branch.goat,
    Branch.monkey,
    Branch.rooster,
    Branch.dog,
    Branch.pig,
  ];
  var julianDay = FullCalenderExtension.convertLunarDateToJulianDay(date);
  return StemBranch(
      stem: stemsOrdered[((julianDay - 1) * 2 + index) % 10],
      branch: branchesOrdered[index]);
}