Fixing DateTime localization issues

1- Some DateTime editors were not using the expected localization formats
2- The DateTime picker was not correctly initialized with localized formats
3- The TimePicker could not handle different am/pm designators
4- The drivers could not accept different designators

Now the am/pm designators used to parse the time and to render it are the one
from WorkContext.CurrentCulture, which means that is zn-TW is used as the
default culture, times will be displayed with "chinese chars here" instead of
AM, and will expect it when parsing it.

--HG--
branch : 1.4.x
This commit is contained in:
Sebastien Ros
2012-05-07 14:50:25 -07:00
parent 2f724c5239
commit b8031b68bd
20 changed files with 1404 additions and 504 deletions

View File

@@ -62,8 +62,8 @@ namespace Orchard.PublishLater.Drivers {
var localDate = new Lazy<DateTime>( () => TimeZoneInfo.ConvertTimeFromUtc(part.ScheduledPublishUtc.Value.Value, Services.WorkContext.CurrentTimeZone));
var model = new PublishLaterViewModel(part) {
ScheduledPublishUtc = part.ScheduledPublishUtc.Value,
ScheduledPublishDate = part.ScheduledPublishUtc.Value.HasValue && !part.IsPublished() ? localDate.Value.ToString(_dateTimeLocalization.ShortDateFormat.Text) : String.Empty,
ScheduledPublishTime = part.ScheduledPublishUtc.Value.HasValue && !part.IsPublished() ? localDate.Value.ToString(_dateTimeLocalization.ShortTimeFormat.Text) : String.Empty,
ScheduledPublishDate = part.ScheduledPublishUtc.Value.HasValue && !part.IsPublished() ? localDate.Value.ToString(_dateTimeLocalization.ShortDateFormat.Text, _cultureInfo.Value) : String.Empty,
ScheduledPublishTime = part.ScheduledPublishUtc.Value.HasValue && !part.IsPublished() ? localDate.Value.ToString(_dateTimeLocalization.ShortTimeFormat.Text, _cultureInfo.Value) : String.Empty,
};
return ContentShape("Parts_PublishLater_Edit",
@@ -83,7 +83,7 @@ namespace Orchard.PublishLater.Drivers {
var dateTimeFormat = _dateTimeLocalization.ShortDateFormat + " " + _dateTimeLocalization.ShortTimeFormat;
// use current culture
if (DateTime.TryParseExact(parseDateTime, dateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out scheduled)) {
if (DateTime.TryParseExact(parseDateTime, dateTimeFormat, _cultureInfo.Value, DateTimeStyles.None, out scheduled)) {
// the date time is entered locally for the configured timezone
var timeZone = Services.WorkContext.CurrentTimeZone;