Fixed bug i CalendarsPicker localization logic where the picker would always use the configured culture formats rather than the IDateTimeFormatProvider abstraction.

This commit is contained in:
Daniel Stolt
2014-08-20 01:20:48 +02:00
parent 2ef4eea1d7
commit 4b0c05c73d

View File

@@ -83,7 +83,7 @@
// Determine the date format to use (convert from short date format string of current culture into jQuery Calendars format string).
// http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
// http://keith-wood.name/calendarsPicker.html#format
var dateFormat = currentCulture.DateTimeFormat.ShortDatePattern.ReplaceAll(new Dictionary<string, string>() {
var dateFormat = dateTimeFormatProvider.ShortDateFormat.ReplaceAll(new Dictionary<string, string>() {
{"dddd", "DD" },
{"ddd", "D" },
{"MMMM", "MM" },
@@ -128,18 +128,18 @@
var dayNamesMin = FormatJsList(dateTimeFormatProvider.DayNamesMin.ToArray());
var firstDay = Convert.ToInt32(dateTimeFormatProvider.FirstDay);
<text>
localizationName = '@HttpUtility.JavaScriptStringEncode(currentCulture.Name)';
$.calendars.calendars.@(calendarName).prototype.regionalOptions[localizationName] = {
monthNames: [@Html.Raw(monthNames)], // Names of months for drop-down and formatting
monthNamesShort: [@Html.Raw(monthNamesShort)], // Short namese of months
dayNames: [@Html.Raw(dayNames)], // Names of days
dayNamesShort: [@Html.Raw(dayNamesShort)], // Short names of days
dayNamesMin: [@Html.Raw(dayNamesMin)], // Column headings for days starting at Sunday
dateFormat: '@HttpUtility.JavaScriptStringEncode(dateFormat)', // See format options on parseDate
firstDay: @firstDay, // First day of the week
isRTL: @(currentCulture.TextInfo.IsRightToLeft ? "true" : "false") // True if right-to-left language, false if left-to-right
localizationName = '@HttpUtility.JavaScriptStringEncode(currentCulture.Name)';
$.calendars.calendars.@(calendarName).prototype.regionalOptions[localizationName] = {
monthNames: [@Html.Raw(monthNames)], // Names of months for drop-down and formatting
monthNamesShort: [@Html.Raw(monthNamesShort)], // Short namese of months
dayNames: [@Html.Raw(dayNames)], // Names of days
dayNamesShort: [@Html.Raw(dayNamesShort)], // Short names of days
dayNamesMin: [@Html.Raw(dayNamesMin)], // Column headings for days starting at Sunday
dateFormat: '@HttpUtility.JavaScriptStringEncode(dateFormat)', // See format options on parseDate
firstDay: @firstDay, // First day of the week
isRTL: @(currentCulture.TextInfo.IsRightToLeft ? "true" : "false") // True if right-to-left language, false if left-to-right
};
</text>
</text>
}
$.calendarsPicker.regionalOptions[localizationName] = {
@@ -166,7 +166,7 @@
dayStatus: '@HttpUtility.JavaScriptStringEncode(T(String.Format("Select {0}", dateFormat)).Text)', // Tooltip text for selectable days
defaultStatus: '@HttpUtility.JavaScriptStringEncode(T("Select a date").Text)', // Tooltip text for areas of the datepicker not covered by one of the other statuses above
isRTL: @(currentCulture.TextInfo.IsRightToLeft ? "true" : "false") // True if right-to-left language, false if left-to-right
};
};
$.calendarsPicker.setDefaults($.calendarsPicker.regionalOptions[localizationName]);
$.calendarsPicker.setDefaults({