DateChooser 2007.07.25版
修正日期分析的Bug
Date.ParseExact()方法居然不能将2007/7/25这样的字符串用yyyy/MM/dd这样的格式符解析,而只能是2007/07/25,没办法,改成用正则表达式来分析了。
2007.07.25版下载
DUDU的版本管理器怎么用,在哪里?
Regex regDateFormat = new Regex(@"([ymd])\1{0,3}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection formatMatches = regDateFormat.Matches(DateFormat);
Regex regDate = new Regex(@"\d+",RegexOptions.Compiled);
MatchCollection dateMatches = regDate.Matches(this._textBox.Text);
int year = 0;
int month = 0;
int day = 0;
for(int i = 0 ; i < formatMatches.Count ; i++)
{
Match match = formatMatches[i];
switch (match.Value[0])
{
case 'Y':
case 'y':
year = int.Parse(dateMatches[i].Value);
break;
case 'M':
case 'm':
month = int.Parse(dateMatches[i].Value);
break;
case 'D':
case 'd':
day = int.Parse(dateMatches[i].Value);
break;
}
}
return new DateTime(year, month, day);
Date.ParseExact()方法居然不能将2007/7/25这样的字符串用yyyy/MM/dd这样的格式符解析,而只能是2007/07/25,没办法,改成用正则表达式来分析了。
2007.07.25版下载
DUDU的版本管理器怎么用,在哪里?
Regex regDateFormat = new Regex(@"([ymd])\1{0,3}", RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection formatMatches = regDateFormat.Matches(DateFormat);
Regex regDate = new Regex(@"\d+",RegexOptions.Compiled);
MatchCollection dateMatches = regDate.Matches(this._textBox.Text);
int year = 0;
int month = 0;
int day = 0;
for(int i = 0 ; i < formatMatches.Count ; i++)
{
Match match = formatMatches[i];
switch (match.Value[0])
{
case 'Y':
case 'y':
year = int.Parse(dateMatches[i].Value);
break;
case 'M':
case 'm':
month = int.Parse(dateMatches[i].Value);
break;
case 'D':
case 'd':
day = int.Parse(dateMatches[i].Value);
break;
}
}
return new DateTime(year, month, day);
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步