chinese_lunar_calendar 0.0.12 copy "chinese_lunar_calendar: ^0.0.12" to clipboard
chinese_lunar_calendar: ^0.0.12 copied to clipboard

A Dart Package for creating Chinese Lunar Calendar. It runs locally and doesn't depend on any remote API.

Chinese Lunar Calendar #

中国万年历查询

本项目参考 cnLunar, 用Dart重写成一个Dart Package。

本地运行,无远程API依赖。

Dart CI License Pub Package publisher

功能 #

  • 查询春节日期.
  • 查询农历日期、干支纪年、生肖。

安装 #

Run this command:

With Dart:

$ dart pub add chinese_lunar_calendar

With Flutter:

$ flutter pub add chinese_lunar_calendar

示例 #

import 'package:chinese_lunar_calendar/chinese_lunar_calendar.dart';

void main() {
  /// 创建LunarCalendar:
  /// 输入查询日期,
  /// 用isSimplifiedCN参数定义使用简体中文或繁体中文,默认为简体中文
  final lunarCalendar =
  LunarCalendar(utcDateTime: DateTime(2023, 6, 5, 10, 30).toUtc(), isSimplifiedCN: true);

  print('中国标准时间:${lunarCalendar.cst}');
  print('本地时间:${lunarCalendar.localTime}');
  print(lunarCalendar.useCSTToCalculate ? '使用中国标准时间计算:' : '使用本地时间计算');
  print('春节: ${lunarCalendar.chineseNewYearString}');
  print(
      '阴历数字: ${lunarCalendar.lunarDate.year}, ${lunarCalendar.lunarDate.month}, ${lunarCalendar.lunarDate.day}, 闰月:${lunarCalendar.lunarDate.isLeapMonth}');
  print('阴历汉字: ${lunarCalendar.lunarDate.fullCNString}');
  print('八字: ${lunarCalendar.eightChar}');
  print('星期:${lunarCalendar.weekDayCN}');
  print('月相:${lunarCalendar.phaseOfMoon}');
  print(
      '本年节气: ${lunarCalendar.solarTerms.values.map((value) => '${value.name}: ${value.getTime(useCSTToCalculate: lunarCalendar.useCSTToCalculate)}').toList()}');
  print('本日节气:${lunarCalendar.todaySolarTerm}');
  print(
      '当前时辰:${lunarCalendar.twoHourPeriod.steamName}${lunarCalendar.twoHourPeriod.name}${lunarCalendar.twoHourPeriod.ke.name}');
  
  final twoHourPeriodsString = lunarCalendar.twoHourPeriodList
      .map((e) =>
  '${e.twoHourPeriodIndex}: ${e.nameInTheDay} (${e.nameInHanDynasty}) ${e.meridian} ${e.isLuckyName}')
      .toList();
  print('本日时辰:$twoHourPeriodsString');
}

输出结果

中国标准时间:2023-06-06 01:30:00.000Z
本地时间:2023-06-05 10:30:00.000
使用本地时间计算
春节: 2023 年 1 月 22 日
阴历数字: 2023, 4, 18, 闰月:false
阴历汉字: 二零二三 癸卯[兔]年 四月大十八
八字: 癸卯 戊午 甲午 己巳
星期:星期一
月相:渐亏凸月
本年节气: [小寒: 2023-01-05 07:05:00.000, 大寒: 2023-01-20 00:30:00.000, 立春: 2023-02-03 18:43:00.000, 雨水: 2023-02-18 14:34:00.000, 惊蛰: 2023-03-05 12:36:00.000, 春分: 2023-03-20 14:24:00.000, 清明: 2023-04-04 18:13:00.000, 谷雨: 2023-04-20 01:14:00.000, 立夏: 2023-05-05 11:19:00.000, 小满: 2023-05-21 00:09:00.000, 芒种: 2023-06-05 15:18:00.000, 夏至: 2023-06-21 07:58:00.000, 小暑: 2023-07-07 01:31:00.000, 大暑: 2023-07-22 18:50:00.000, 立秋: 2023-08-07 11:23:00.000, 处暑: 2023-08-23 02:01:00.000, 白露: 2023-09-07 14:27:00.000, 秋分: 2023-09-22 23:50:00.000, 寒露: 2023-10-08 06:16:00.000, 霜降: 2023-10-23 09:21:00.000, 立冬: 2023-11-07 08:36:00.000, 小雪: 2023-11-22 07:03:00.000, 大雪: 2023-12-07 01:33:00.000, 冬至: 2023-12-21 19:27:00.000]
本日节气:SolarTerm(name: 芒种, CST: 2023-06-06 06:18:00.000Z, UTC: 2023-06-05 22:18:00.000Z, Local: 2023-06-05 15:18:00.000)
当前时辰:己巳正 三刻
本日时辰:[0: 甲子 (夜半) 胆 吉, 1: 乙丑 (鸡鸣) 肝 吉, 2: 丙寅 (平旦) 肺 凶, 3: 丁卯 (日出) 大肠 吉, 4: 戊辰 (食时) 胃 凶, 5: 己巳 (隅中) 脾 凶, 6: 庚午 (日中) 心 吉, 7: 辛未 (日昳) 小肠 凶, 8: 壬申 (晡时) 膀胱 吉, 9: 癸酉 (日入) 肾 吉, 10: 甲戌 (黄昏) 心包 凶, 11: 乙亥 (人定) 三焦 凶]
6
likes
0
pub points
67%
popularity

Publisher

verified publishermintminter.dev

A Dart Package for creating Chinese Lunar Calendar. It runs locally and doesn't depend on any remote API.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

collection, equatable

More

Packages that depend on chinese_lunar_calendar