StemBranch.month constructor
Creates a month's StemBranch instance based on the given this month
and year
of this month
.
Implementation
factory StemBranch.month(int month, int year) {
final stemsYearOrdered = [
Stem.yangMetal,
Stem.yinMetal,
Stem.yangWater,
Stem.yinWater,
Stem.yangWood,
Stem.yinWood,
Stem.yangFire,
Stem.yinFire,
Stem.yangEarth,
Stem.yinEarth,
];
final stemsJanIndexOrdered = [8, 0, 2, 4, 6, 8, 0, 2, 4, 6];
final branchesMonthOrdered = [
Branch.tiger,
Branch.rabbit,
Branch.dragon,
Branch.snake,
Branch.horse,
Branch.goat,
Branch.monkey,
Branch.rooster,
Branch.dog,
Branch.pig,
Branch.rat,
Branch.ox,
];
final stemYearIndex = year % 10;
var steamMonthIndex =
(stemsJanIndexOrdered[stemYearIndex] + month - 1) % 10;
return StemBranch(
stem: stemsYearOrdered[steamMonthIndex],
branch: branchesMonthOrdered[month - 1]);
}