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

v8.1.1 #20

Merged
merged 3 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</p>
<p align="center">
<a target="_blank" href="https://search.maven.org/search?q=org.miaixz">
<img src="https://img.shields.io/badge/maven--central-v8.1.0-blue.svg?label=Maven%20Central" />
<img src="https://img.shields.io/badge/maven--central-v8.1.1-blue.svg?label=Maven%20Central" />
</a>
<a target="_blank" href="https://travis-ci.org/839128/bus">
<img src="https://app.travis-ci.com/839128/bus.svg?token=TZPNK5FQiKMp9cao3SnY&branch=main">
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.1.0
8.1.1
2 changes: 1 addition & 1 deletion bus-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>org.miaixz</groupId>
<artifactId>bus-all</artifactId>
<version>8.1.0</version>
<version>8.1.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>org.miaixz</groupId>
<artifactId>bus-base</artifactId>
<version>8.1.0</version>
<version>8.1.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>org.miaixz</groupId>
<artifactId>bus-bom</artifactId>
<version>8.1.0</version>
<version>8.1.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-cache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>org.miaixz</groupId>
<artifactId>bus-cache</artifactId>
<version>8.1.0</version>
<version>8.1.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<groupId>org.miaixz</groupId>
<artifactId>bus-core</artifactId>
<version>8.1.0</version>
<version>8.1.1</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down
2 changes: 1 addition & 1 deletion bus-core/src/main/java/org/miaixz/bus/core/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Version implements Comparable<Version>, Serializable {
/**
* 版本信息
*/
public static final String _VERSION = "8.1.0";
public static final String _VERSION = "8.1.1";

private static final long serialVersionUID = -1L;
private final String version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.miaixz.bus.core.center.function.FunctionX;
import org.miaixz.bus.core.lang.Optional;
Expand Down Expand Up @@ -389,4 +390,23 @@ public static <K, X, Y, V> Map<K, V> merge(Map<K, X> map1, Map<K, Y> map2, final
return map;
}

/**
* 笛卡尔积 参考:https://www.baeldung-cn.com/java-cartesian-product-sets
*
* @param sets 集合列表
* @param index 索引
* @return 笛卡尔积
*/
public static Stream<List<Object>> cartesianProduct(final List<List<Object>> sets, final int index) {
if (index == sets.size()) {
return Stream.of(ListKit.zero());
}
final List<Object> currentSet = sets.get(index);
return currentSet.stream().flatMap(element -> cartesianProduct(sets, index + 1).map(list -> {
final List<Object> newList = new ArrayList<>(list);
newList.add(0, element);
return newList;
}));
}

}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,7 @@ public JulianDay next(int n) {
* @return 公历日
*/
public SolarDay getSolarDay() {
int d = (int) (this.day + 0.5);
double f = this.day + 0.5 - d;

if (d >= 2299161) {
int c = (int) ((d - 1867216.25) / 36524.25);
d += 1 + c - (int) (c * 1D / 4);
}
d += 1524;
int year = (int) ((d - 122.1) / 365.25);
d -= (int) (365.25 * year);
int month = (int) (d * 1D / 30.601);
d -= (int) (30.601 * month);
int day = d;
if (month > 13) {
month -= 13;
year -= 4715;
} else {
month -= 1;
year -= 4716;
}
f *= 24;
int hour = (int) f;

f -= hour;
f *= 60;
int minute = (int) f;

f -= minute;
f *= 60;
int second = (int) Math.round(f);
if (second > 59) {
minute++;
}
if (minute > 59) {
hour++;
}
if (hour > 23) {
day += 1;
}
return SolarDay.fromYmd(year, month, day);
return getSolarTime().getSolarDay();
}

/**
Expand Down Expand Up @@ -183,7 +144,7 @@ public SolarTime getSolarTime() {
}
if (hour > 23) {
hour -= 24;
day += 1;
day++;
}
return SolarTime.fromYmdHms(year, month, day, hour, minute, second);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,7 @@ public static Taboo fromName(String name) {
* @return 宜忌列表
*/
public static List<Taboo> getDayRecommends(SixtyCycle month, SixtyCycle day) {
List<Taboo> l = new ArrayList<>();
String data = dayTaboo[month.getEarthBranch().getIndex()].split(";", -1)[day.getIndex()].split(",", -1)[0];
for (int i = 0, j = data.length(); i < j; i += 2) {
l.add(Taboo.fromIndex(Integer.parseInt(data.substring(i, i + 2), 16)));
}
return l;
return getTaboos(dayTaboo, month.getEarthBranch().getIndex(), day.getIndex(), 0);
}

/**
Expand All @@ -125,12 +120,7 @@ public static List<Taboo> getDayRecommends(SixtyCycle month, SixtyCycle day) {
* @return 宜忌列表
*/
public static List<Taboo> getDayAvoids(SixtyCycle month, SixtyCycle day) {
List<Taboo> l = new ArrayList<>();
String data = dayTaboo[month.getEarthBranch().getIndex()].split(";", -1)[day.getIndex()].split(",", -1)[1];
for (int i = 0, j = data.length(); i < j; i += 2) {
l.add(Taboo.fromIndex(Integer.parseInt(data.substring(i, i + 2), 16)));
}
return l;
return getTaboos(dayTaboo, month.getEarthBranch().getIndex(), day.getIndex(), 1);
}

/**
Expand All @@ -141,12 +131,7 @@ public static List<Taboo> getDayAvoids(SixtyCycle month, SixtyCycle day) {
* @return 宜忌列表
*/
public static List<Taboo> getHourRecommends(SixtyCycle day, SixtyCycle hour) {
List<Taboo> l = new ArrayList<>();
String data = hourTaboo[hour.getEarthBranch().getIndex()].split(";", -1)[day.getIndex()].split(",", -1)[0];
for (int i = 0, j = data.length(); i < j; i += 2) {
l.add(Taboo.fromIndex(Integer.parseInt(data.substring(i, i + 2), 16)));
}
return l;
return getTaboos(hourTaboo, hour.getEarthBranch().getIndex(), day.getIndex(), 0);
}

/**
Expand All @@ -157,16 +142,20 @@ public static List<Taboo> getHourRecommends(SixtyCycle day, SixtyCycle hour) {
* @return 宜忌列表
*/
public static List<Taboo> getHourAvoids(SixtyCycle day, SixtyCycle hour) {
List<Taboo> l = new ArrayList<>();
String data = hourTaboo[hour.getEarthBranch().getIndex()].split(";", -1)[day.getIndex()].split(",", -1)[1];
for (int i = 0, j = data.length(); i < j; i += 2) {
l.add(Taboo.fromIndex(Integer.parseInt(data.substring(i, i + 2), 16)));
}
return l;
return getTaboos(hourTaboo, hour.getEarthBranch().getIndex(), day.getIndex(), 1);
}

public Taboo next(int n) {
return fromIndex(nextIndex(n));
}

private static List<Taboo> getTaboos(String[] data, int supIndex, int subIndex, int index) {
List<Taboo> l = new ArrayList<>();
String d = data[supIndex].split(";", -1)[subIndex].split(",", -1)[index];
for (int i = 0, j = d.length(); i < j; i += 2) {
l.add(Taboo.fromIndex(Integer.parseInt(d.substring(i, i + 2), 16)));
}
return l;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.birth;
package org.miaixz.bus.core.center.date.culture.cn.eightchar;

import org.miaixz.bus.core.center.date.culture.cn.Opposite;
import org.miaixz.bus.core.center.date.culture.cn.birth.provider.ChildLimitProvider;
import org.miaixz.bus.core.center.date.culture.cn.birth.provider.impl.DefaultChildLimitProvider;
import org.miaixz.bus.core.center.date.culture.cn.eightchar.provider.ChildLimitProvider;
import org.miaixz.bus.core.center.date.culture.cn.eightchar.provider.impl.DefaultChildLimitProvider;
import org.miaixz.bus.core.center.date.culture.solar.SolarTerms;
import org.miaixz.bus.core.center.date.culture.solar.SolarTime;
import org.miaixz.bus.core.lang.Gender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.birth;
package org.miaixz.bus.core.center.date.culture.cn.eightchar;

import org.miaixz.bus.core.center.date.culture.solar.SolarTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.birth;
package org.miaixz.bus.core.center.date.culture.cn.eightchar;

import org.miaixz.bus.core.center.date.culture.Loops;
import org.miaixz.bus.core.center.date.culture.cn.sixty.SixtyCycle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.birth;
package org.miaixz.bus.core.center.date.culture.cn.eightchar;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.birth;
package org.miaixz.bus.core.center.date.culture.cn.eightchar;

import org.miaixz.bus.core.center.date.culture.Loops;
import org.miaixz.bus.core.center.date.culture.cn.sixty.SixtyCycle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
* @author Kimi Liu
* @since Java 17+
*/
package org.miaixz.bus.core.center.date.culture.cn.birth;
package org.miaixz.bus.core.center.date.culture.cn.eightchar;
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.birth.provider;
package org.miaixz.bus.core.center.date.culture.cn.eightchar.provider;

import org.miaixz.bus.core.center.date.culture.cn.birth.ChildLimitInfo;
import org.miaixz.bus.core.center.date.culture.cn.eightchar.ChildLimitInfo;
import org.miaixz.bus.core.center.date.culture.solar.SolarTerms;
import org.miaixz.bus.core.center.date.culture.solar.SolarTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ ~
~ The MIT License (MIT) ~
~ ~
~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~
~ ~
~ Permission is hereby granted, free of charge, to any person obtaining a copy ~
~ of this software and associated documentation files (the "Software"), to deal ~
~ in the Software without restriction, including without limitation the rights ~
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~
~ copies of the Software, and to permit persons to whom the Software is ~
~ furnished to do so, subject to the following conditions: ~
~ ~
~ The above copyright notice and this permission notice shall be included in ~
~ all copies or substantial portions of the Software. ~
~ ~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~
~ THE SOFTWARE. ~
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*/
package org.miaixz.bus.core.center.date.culture.cn.eightchar.provider;

import org.miaixz.bus.core.center.date.culture.cn.eightchar.EightChar;
import org.miaixz.bus.core.center.date.culture.lunar.LunarHour;

/**
* 八字计算接口
*
* @author Kimi Liu
* @since Java 17+
*/
public interface EightCharProvider {

/**
* 八字
*
* @param hour 农历时辰
* @return 八字
*/
EightChar getEightChar(LunarHour hour);

}
Loading
Loading