Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Provide new class variables for CN format too in Lunar Class #1

Open
sgon00 opened this issue Apr 14, 2019 · 0 comments

Comments

@sgon00
Copy link

sgon00 commented Apr 14, 2019

First, Thank you very much for this project.

Can you please provide new class variables for CN format too in Lunar Class?
I am not sure what variable names you like. I use the following modified code for now:

class Lunar {
  String get lunarYearCN {
    int year = lunarYear;
    if (year < 0) {
      //确保能读到正确的天干地支数据
      year++;
    }
    if (year < 1900) {
      //把远古年代转到近代来计算天干地支
      year += ((2018 - year) / 60).floor() * 60;
    }
    int absYear = lunarYear.abs();
    String prefix = (lunarYear < 0 ? "公元前" : "") + "$absYear";
    return ((_tiangan[(year - 4) % _tiangan.length]) + (_dizhi[(year - 4) % _dizhi.length]) + "年");
  }

  String get lunarMonthCN {
    if (lunarMonth < 1 || lunarMonth > 12) {
      return "非法日期";
    }
    String month = _lunarMonthList[lunarMonth - 1];
    String leap = isLeap ? "闰" : "";
    return "$leap$month月";
  }

  String get lunarDayCN {
    if (lunarDay < 1 || lunarDay > 30) {
      return "非法日期";
    }
    return _lunarDayList[lunarDay - 1];
  }
}

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant