From adb48f42d77002b897303a187c4029f7d4c34ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=A0=E6=96=87=E8=BD=A9?= <12812285557@qq.com> Date: Mon, 6 Jun 2022 09:43:33 +0800 Subject: [PATCH] fix bug --- .idea/workspace.xml | 25 ++++--------------------- lib/model/date_model.dart | 4 ++-- lib/utils/lunar_util.dart | 16 ++++++++-------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b4a3804..43fb2ca 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,9 +10,9 @@ - - - + + + - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/model/date_model.dart b/lib/model/date_model.dart index 326c60a..10665db 100644 --- a/lib/model/date_model.dart +++ b/lib/model/date_model.dart @@ -9,7 +9,7 @@ class DateModel { int? month; int day = 1; - List lunar = []; + List lunar = []; // List get lunar { // if (lunar?.isNotEmpty == false) { @@ -86,7 +86,7 @@ class DateModel { ..year = dateTime.year ..month = dateTime.month ..day = dateTime.day; - List lunar = + List lunar = LunarUtil.solarToLunar(dateModel.year!, dateModel.month!, dateModel.day); dateModel.lunar = lunar; diff --git a/lib/utils/lunar_util.dart b/lib/utils/lunar_util.dart index 59a3970..91fe09a 100644 --- a/lib/utils/lunar_util.dart +++ b/lib/utils/lunar_util.dart @@ -764,7 +764,7 @@ class LunarUtil { // dateModel.isLeapYear = DateUtil.isLeapYear(year); // dateModel.isCurrentDay = DateUtil.isCurrentDay(year, month, day); - List lunar = LunarUtil.solarToLunar(2020, 2, day); + List lunar = LunarUtil.solarToLunar(2020, 2, day); // dateModel.lunarYear = (lunar[0]); // dateModel.lunarMonth = (lunar[1]); @@ -808,8 +808,8 @@ class LunarUtil { * @param day 公历日 * @return [0]农历年 [1]农历月 [2]农历日 [3]是否闰月 0 false : 1 true */ - static List solarToLunar(int year, int month, int day) { - List lunarInt = []; + static List solarToLunar(int year, int month, int day) { + List lunarInt = [0,0,0,0]; int index = year - SOLAR[0]; int data = (year << 9) | (month << 5) | (day); int solar11; @@ -861,12 +861,12 @@ class LunarUtil { static int solarToInt(int y, int m, int d) { m = (m + 9) % 12; - y = y - (m / 10).toInt(); + y = y - m ~/ 10; return (365 * y + - (y / 4).toInt() - - (y / 100).toInt() + - (y / 400).toInt() + - ((m * 306 + 5) / 10).toInt() + + y ~/ 4 - + y ~/ 100 + + y ~/ 400 + + (m * 306 + 5) ~/ 10 + (d - 1)); }