mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Added support for the year/month and month/day date patterns to CultureDateTimeFormatProvider and DefaultDateFormatter. ALL standard formats are now fully supported - yaaay!
This commit is contained in:
@@ -109,6 +109,8 @@ namespace Orchard.Localization.Services {
|
||||
var patterns = new List<string>();
|
||||
patterns.AddRange(DateTimeFormat.GetAllDateTimePatterns('d'));
|
||||
patterns.AddRange(DateTimeFormat.GetAllDateTimePatterns('D'));
|
||||
patterns.AddRange(DateTimeFormat.GetAllDateTimePatterns('m'));
|
||||
patterns.AddRange(DateTimeFormat.GetAllDateTimePatterns('y'));
|
||||
// The standard format strings 'M' (month/day pattern) and 'Y' (year/month
|
||||
// pattern) are excluded because they can not be round-tripped with full
|
||||
// date fidelity.
|
||||
|
@@ -128,7 +128,7 @@ namespace Orchard.Localization.Services {
|
||||
|
||||
protected virtual DateTimeParts? TryParseDateTime(string dateTimeString, string format, IDictionary<string, string> replacements) {
|
||||
var dateTimePattern = ConvertFormatStringToRegexPattern(format, replacements);
|
||||
Match m = Regex.Match(dateTimeString.Trim(), dateTimePattern, RegexOptions.IgnoreCase);
|
||||
Match m = Regex.Match(dateTimeString, dateTimePattern, RegexOptions.IgnoreCase);
|
||||
if (m.Success) {
|
||||
return new DateTimeParts(ExtractDateParts(m), ExtractTimeParts(m));
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace Orchard.Localization.Services {
|
||||
|
||||
protected virtual DateParts? TryParseDate(string dateString, string format, IDictionary<string, string> replacements) {
|
||||
var datePattern = ConvertFormatStringToRegexPattern(format, replacements);
|
||||
Match m = Regex.Match(dateString.Trim(), datePattern, RegexOptions.IgnoreCase);
|
||||
Match m = Regex.Match(dateString, datePattern, RegexOptions.IgnoreCase);
|
||||
if (m.Success) {
|
||||
return ExtractDateParts(m);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ namespace Orchard.Localization.Services {
|
||||
|
||||
protected virtual TimeParts? TryParseTime(string timeString, string format, IDictionary<string, string> replacements) {
|
||||
var timePattern = ConvertFormatStringToRegexPattern(format, replacements);
|
||||
Match m = Regex.Match(timeString.Trim(), timePattern, RegexOptions.IgnoreCase);
|
||||
Match m = Regex.Match(timeString, timePattern, RegexOptions.IgnoreCase);
|
||||
if (m.Success) {
|
||||
return ExtractTimeParts(m);
|
||||
}
|
||||
|
Reference in New Issue
Block a user