Skip to content

Commit d3b3d68

Browse files
author
linzhijun
committed
修复DATEDIF不能正确处理10月的问题
1 parent d189854 commit d3b3d68

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

csharp/ToolGood.Algorithm2/MyDate.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static MyDate Parse(String txt)
119119
{
120120
CultureInfo cultureInfo = CultureInfo.GetCultureInfo("en-US");
121121
String t = txt.Trim();
122-
var m = Regex.Match(t, "^(\\d{4})-(11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d):([012345]?\\d)$", RegexOptions.Compiled);
122+
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);
123123
if (m.Success) {
124124
MyDate date = new MyDate();
125125
date.Year = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -130,7 +130,7 @@ public static MyDate Parse(String txt)
130130
date.Second = int.Parse(m.Groups[(6)].Value, cultureInfo);
131131
return date;
132132
}
133-
m = Regex.Match(t, "^(\\d{4})-(11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d)$", RegexOptions.Compiled);
133+
m = Regex.Match(t, "^(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d) ([01]\\d?|2[1234]):([012345]?\\d)$", RegexOptions.Compiled);
134134
if (m.Success) {
135135
MyDate date = new MyDate();
136136
date.Year = int.Parse(m.Groups[(1)].Value, cultureInfo);
@@ -140,7 +140,7 @@ public static MyDate Parse(String txt)
140140
date.Minute = int.Parse(m.Groups[(5)].Value, cultureInfo);
141141
return date;
142142
}
143-
m = Regex.Match(t, "^(\\d{4})-(11|12|0?\\d)-(30|31|[012]?\\d)$");
143+
m = Regex.Match(t, "^(\\d{4})-(10|11|12|0?\\d)-(30|31|[012]?\\d)$");
144144
if (m.Success) {
145145
MyDate date = new MyDate();
146146
date.Year = int.Parse(m.Groups[(1)].Value, cultureInfo);

0 commit comments

Comments
 (0)