Fix pre-1900 dates in the datepicker causing a crash on Windows (bug 354073). Thanks to <gekacheka@yahoo.com> for the patch; r1=ssitter@googlemail.com, r2=dmose

This commit is contained in:
dmose%mozilla.org 2006-09-27 18:11:07 +00:00
Родитель 47a6bbbdfe
Коммит c3a2330083
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -1714,10 +1714,21 @@
</method>
<method name="formatDate">
<parameter name="aValue"/>
<parameter name="aDate"/>
<body>
<![CDATA[
return aValue.toLocaleFormat("%x");
// workaround for bugs 354073/327869:
// aDate.toLocaleFormat("%x") exits application
// if year before 1900 (e.g., typo) on MSWindows (due to MS bug).
var nsIScriptableDateFormat =
Components.interfaces.nsIScriptableDateFormat;
var dateService =
Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(nsIScriptableDateFormat);
return dateService.FormatDate("", dateService.dateFormatShort,
aDate.getFullYear(),
aDate.getMonth()+1,
aDate.getDate());
]]>
</body>
</method>