diff --git a/csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_dateTime.cs b/csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_dateTime.cs
index 0dab7206..6e31a9aa 100644
--- a/csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_dateTime.cs
+++ b/csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_dateTime.cs
@@ -267,6 +267,31 @@ public void Add_test()
dt = engine.TryEvaluate("'2000-02-01 12:05:06'.AddSeconds(1).Second()", 0);
Assert.AreEqual(dt, 7);
+ dt = engine.TryEvaluate("'2000-02-01 10:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 7);
+
+ dt = engine.TryEvaluate("'2000-02-01 20:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 7);
+
+ dt = engine.TryEvaluate("'2000-02-01 9:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 7);
+
+ dt = engine.TryEvaluate("'7:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 7);
+
+ dt = engine.TryEvaluate("'10:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 7);
+
+ dt = engine.TryEvaluate("'20:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 7);
+
+ // 错误
+ dt = engine.TryEvaluate("'2000-02-01 24:05:06'.AddSeconds(1).Second()", 0);
+ Assert.AreEqual(dt, 0);
+
+ //
+ //dt = engine.TryEvaluate("'24:05:06'.AddSeconds(1).Second()", 0);
+ //Assert.AreEqual(dt, 0);
}
}
diff --git a/csharp/ToolGood.Algorithm2/MyDate.cs b/csharp/ToolGood.Algorithm2/MyDate.cs
index d528829f..e1290f06 100644
--- a/csharp/ToolGood.Algorithm2/MyDate.cs
+++ b/csharp/ToolGood.Algorithm2/MyDate.cs
@@ -119,7 +119,7 @@ public static MyDate Parse(String txt)
{
CultureInfo cultureInfo = CultureInfo.GetCultureInfo("en-US");
String t = txt.Trim();
- var m = Regex.Match(t, "^(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
+ var m = Regex.Match(t, "^(\\d{4})-(1[012]|0?\\d)-(30|31|[012]?\\d) ([01]?\\d|2[0123]):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
if (m.Success) {
MyDate date = new MyDate();
date.Year = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -130,7 +130,7 @@ public static MyDate Parse(String txt)
date.Second = int.Parse(m.Groups[(6)].Value, cultureInfo);
return date;
}
- m = Regex.Match(t, "^(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d)$", RegexOptions.Compiled);
+ m = Regex.Match(t, "^(\\d{4})-(1[012]|0?\\d)-(30|31|[012]?\\d) ([01]?\\d|2[0123]):([012345]?\\d)$", RegexOptions.Compiled);
if (m.Success) {
MyDate date = new MyDate();
date.Year = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -140,7 +140,7 @@ public static MyDate Parse(String txt)
date.Minute = int.Parse(m.Groups[(5)].Value, cultureInfo);
return date;
}
- m = Regex.Match(t, "^(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d)$");
+ m = Regex.Match(t, "^(\\d{4})-(1[012]|0?\\d)-(30|31|[012]?\\d)$");
if (m.Success) {
MyDate date = new MyDate();
date.Year = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -148,7 +148,7 @@ public static MyDate Parse(String txt)
date.Day = int.Parse(m.Groups[(3)].Value, cultureInfo);
return date;
}
- m = Regex.Match(t, "^(\\d+) (2[1234]|[01]?\\d):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
+ m = Regex.Match(t, "^(\\d+) (2[0123]|[01]?\\d):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
if (m.Success) {
MyDate date = new MyDate();
date.Day = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -157,7 +157,7 @@ public static MyDate Parse(String txt)
date.Second = int.Parse(m.Groups[(4)].Value, cultureInfo);
return date;
}
- m = Regex.Match(t, "^(2[1234]|[01]?\\d):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
+ m = Regex.Match(t, "^(2[0123]|[01]?\\d):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
if (m.Success) {
MyDate date = new MyDate();
date.Hour = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -165,7 +165,7 @@ public static MyDate Parse(String txt)
date.Second = int.Parse(m.Groups[(3)].Value, cultureInfo);
return date;
}
- m = Regex.Match(t, "^(2[1234]|[01]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
+ m = Regex.Match(t, "^(2[0123]|[01]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
if (m.Success) {
MyDate date = new MyDate();
date.Hour = int.Parse(m.Groups[(1)].Value, cultureInfo);
diff --git a/csharp/ToolGood.Algorithm2/ToolGood.Algorithm2.csproj b/csharp/ToolGood.Algorithm2/ToolGood.Algorithm2.csproj
index 3a1d42b0..578f903a 100644
--- a/csharp/ToolGood.Algorithm2/ToolGood.Algorithm2.csproj
+++ b/csharp/ToolGood.Algorithm2/ToolGood.Algorithm2.csproj
@@ -20,7 +20,7 @@
ToolGood.Algorithm
LICENSE
true
- 3.4.1.2
+ 3.4.1.3
ToolGood.Algorithm.snk
false
bin\$(Configuration)\$(TargetFramework)\ToolGood.Algorithm.xml
diff --git a/java/toolgood.algorithm/pom.xml b/java/toolgood.algorithm/pom.xml
index ef6944f3..a09c5f4f 100644
--- a/java/toolgood.algorithm/pom.xml
+++ b/java/toolgood.algorithm/pom.xml
@@ -6,7 +6,7 @@
io.github.toolgood
toolgood-algorithm
- 3.4.1.2
+ 3.4.1.3
jar
toolgood.algorithm
diff --git a/java/toolgood.algorithm/src/main/java/toolgood/algorithm/MyDate.java b/java/toolgood.algorithm/src/main/java/toolgood/algorithm/MyDate.java
index 9caa4282..9cb53c5d 100644
--- a/java/toolgood.algorithm/src/main/java/toolgood/algorithm/MyDate.java
+++ b/java/toolgood.algorithm/src/main/java/toolgood/algorithm/MyDate.java
@@ -113,7 +113,7 @@ public MyDate(double num) {
public static MyDate parse(String txt) {
String t = txt.trim();
Matcher m = Pattern
- .compile("^(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d):([012345]?\\d)$")
+ .compile("^(\\d{4})-(1[012]|0?\\d)-(30|31|[012]?\\d) ([01]?\\d|2[0123]):([012345]?\\d):([012345]?\\d)$")
.matcher(t);
if (m.find()) {
MyDate date = new MyDate();
@@ -125,7 +125,7 @@ public static MyDate parse(String txt) {
date.Second = Integer.parseInt(m.group(6));
return date;
}
- m = Pattern.compile("(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d)").matcher(t);
+ m = Pattern.compile("(\\d{4})-(1[012]|0?\\d)-(30|31|[012]?\\d) ([01]?\\d|2[0123]):([012345]?\\d)").matcher(t);
if (m.find()) {
MyDate date = new MyDate();
date.Year = Integer.parseInt(m.group(1));
@@ -135,7 +135,7 @@ public static MyDate parse(String txt) {
date.Minute = Integer.parseInt(m.group(5));
return date;
}
- m = Pattern.compile("(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d)").matcher(t);
+ m = Pattern.compile("(\\d{4})-(1[012]|0?\\d)-(30|31|[012]?\\d)").matcher(t);
if (m.find()) {
MyDate date = new MyDate();
date.Year = Integer.parseInt(m.group(1));
@@ -143,7 +143,7 @@ public static MyDate parse(String txt) {
date.Day = Integer.parseInt(m.group(3));
return date;
}
- m = Pattern.compile("^(\\d+) (2[1234]|[01]?\\d):([012345]?\\d):([012345]?\\d)$").matcher(t);
+ m = Pattern.compile("^(\\d+) (2[0123]|[01]?\\d):([012345]?\\d):([012345]?\\d)$").matcher(t);
if (m.find()) {
MyDate date = new MyDate();
date.Day = Integer.parseInt(m.group(1));
@@ -152,7 +152,7 @@ public static MyDate parse(String txt) {
date.Second = Integer.parseInt(m.group(4));
return date;
}
- m = Pattern.compile("^(2[1234]|[01]?\\d):([012345]?\\d):([012345]?\\d)$").matcher(t);
+ m = Pattern.compile("^(2[0123]|[01]?\\d):([012345]?\\d):([012345]?\\d)$").matcher(t);
if (m.find()) {
MyDate date = new MyDate();
date.Hour = Integer.parseInt(m.group(1));
@@ -160,7 +160,7 @@ public static MyDate parse(String txt) {
date.Second = Integer.parseInt(m.group(3));
return date;
}
- m = Pattern.compile("^(2[1234]|[01]?\\d):([012345]?\\d)$").matcher(t);
+ m = Pattern.compile("^(2[0123]|[01]?\\d):([012345]?\\d)$").matcher(t);
if (m.find()) {
MyDate date = new MyDate();
date.Hour = Integer.parseInt(m.group(1));