MCPcopy Create free account
hub / github.com/6tail/lunar-java / getFu

Method getFu

src/main/java/com/nlf/calendar/Lunar.java:2911–2960  ·  view source on GitHub ↗

获取三伏 @return 三伏,如果不是伏天,返回null

()

Source from the content-addressed store, hash-verified

2909 * @return 三伏,如果不是伏天,返回null
2910 */
2911 public Fu getFu() {
2912 Solar current = Solar.fromYmd(solar.getYear(), solar.getMonth(), solar.getDay());
2913 Solar xiaZhi = jieQi.get("夏至");
2914 Solar liQiu = jieQi.get("立秋");
2915 Solar start = Solar.fromYmd(xiaZhi.getYear(), xiaZhi.getMonth(), xiaZhi.getDay());
2916 // 第1个庚日
2917 int add = 6 - xiaZhi.getLunar().getDayGanIndex();
2918 if (add < 0) {
2919 add += 10;
2920 }
2921 // 第3个庚日,即初伏第1天
2922 add += 20;
2923 start = start.next(add);
2924
2925 // 初伏以前
2926 if (current.isBefore(start)) {
2927 return null;
2928 }
2929
2930 int days = current.subtract(start);
2931 if (days < 10) {
2932 return new Fu("初伏", days + 1);
2933 }
2934
2935 // 第4个庚日,中伏第1天
2936 start = start.next(10);
2937 days = current.subtract(start);
2938 if (days < 10) {
2939 return new Fu("中伏", days + 1);
2940 }
2941
2942 // 第5个庚日,中伏第11天或末伏第1天
2943 start = start.next(10);
2944 days = current.subtract(start);
2945 Solar liQiuSolar = Solar.fromYmd(liQiu.getYear(), liQiu.getMonth(), liQiu.getDay());
2946 // 末伏
2947 if (liQiuSolar.isAfter(start)) {
2948 // 中伏
2949 if (days < 10) {
2950 return new Fu("中伏", days + 11);
2951 }
2952 // 末伏第1天
2953 start = start.next(10);
2954 days = current.subtract(start);
2955 }
2956 if (days < 10) {
2957 return new Fu("末伏", days + 1);
2958 }
2959 return null;
2960 }
2961
2962 /**
2963 * 获取六曜

Callers 14

test1Method · 0.95
test2Method · 0.95
test3Method · 0.95
test4Method · 0.95
test5Method · 0.95
test6Method · 0.95
test7Method · 0.95
test8Method · 0.95
test9Method · 0.95
test10Method · 0.95
test11Method · 0.95
test12Method · 0.95

Calls 13

fromYmdMethod · 0.95
getYearMethod · 0.95
getMonthMethod · 0.95
getDayMethod · 0.95
getLunarMethod · 0.95
nextMethod · 0.95
isBeforeMethod · 0.95
subtractMethod · 0.95
isAfterMethod · 0.95
getYearMethod · 0.45
getMonthMethod · 0.45
getDayMethod · 0.45

Tested by 14

test1Method · 0.76
test2Method · 0.76
test3Method · 0.76
test4Method · 0.76
test5Method · 0.76
test6Method · 0.76
test7Method · 0.76
test8Method · 0.76
test9Method · 0.76
test10Method · 0.76
test11Method · 0.76
test12Method · 0.76