getDayJi static method

List<String> getDayJi(
  1. String monthGanZhi,
  2. String dayGanZhi
)

Implementation

static List<String> getDayJi(String monthGanZhi, String dayGanZhi) {
  List<String> l = <String>[];
  String day = hex(getJiaZiIndex(dayGanZhi));
  String month = hex(getJiaZiIndex(monthGanZhi));
  String right = DAY_YI_JI;
  int index = right.indexOf(day + '=');
  while (index > -1) {
    right = right.substring(index + 3);
    String left = right;
    if (left.contains('=')) {
      left = left.substring(0, left.indexOf('=') - 2);
    }
    bool matched = false;
    String months = left.substring(0, left.indexOf(':'));
    for (int i = 0, j = months.length; i < j; i += 2) {
      if (months.substring(i, i + 2) == month) {
        matched = true;
        break;
      }
    }
    if (matched) {
      String js = left.substring(left.indexOf(',') + 1);
      for (int i = 0, j = js.length; i < j; i += 2) {
        l.add(YI_JI[int.parse(js.substring(i, i + 2), radix: 16)]);
      }
      break;
    }
    index = right.indexOf(day + '=');
  }
  if (l.isEmpty) {
    l.add('无');
  }
  return l;
}