Bug 381927 - end times in download manager properties are wrong or missing. r=mano

This commit is contained in:
sdwilsh@shawnwilsher.com 2007-06-12 16:43:02 -07:00
Родитель 2b8c31c104
Коммит 098c5d5966
1 изменённых файлов: 27 добавлений и 22 удалений

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

@ -40,12 +40,12 @@ function Startup()
{ {
const dlmgrContractID = "@mozilla.org/download-manager;1"; const dlmgrContractID = "@mozilla.org/download-manager;1";
const dlmgrIID = Components.interfaces.nsIDownloadManager; const dlmgrIID = Components.interfaces.nsIDownloadManager;
var downloadMgr = Components.classes[dlmgrContractID].getService(dlmgrIID); var dm = Components.classes[dlmgrContractID].getService(dlmgrIID);
var db = downloadMgr.DBConnection; var db = dm.DBConnection;
const dateTimeContractID = "@mozilla.org/intl/scriptabledateformat;1"; const dateTimeContractID = "@mozilla.org/intl/scriptabledateformat;1";
const dateTimeIID = Components.interfaces.nsIScriptableDateFormat; const dateTimeIID = Components.interfaces.nsIScriptableDateFormat;
var dateTimeService = Components.classes[dateTimeContractID].getService(dateTimeIID); var dts = Components.classes[dateTimeContractID].getService(dateTimeIID);
var dateStartedField = document.getElementById("dateStarted"); var dateStartedField = document.getElementById("dateStarted");
var dateEndedField = document.getElementById("dateEnded"); var dateEndedField = document.getElementById("dateEnded");
@ -60,31 +60,36 @@ function Startup()
stmt.bindInt64Parameter(0, dlid); stmt.bindInt64Parameter(0, dlid);
stmt.executeStep(); stmt.executeStep();
try { var dateStarted = new Date(stmt.getInt64(0) / 1000);
var dateStarted = stmt.getInt64(0); dateStarted = dts.FormatDateTime("", dts.dateFormatShort,
dateStarted = new Date(dateStarted/1000); dts.timeFormatSeconds,
dateStarted = dateTimeService.FormatDateTime("", dateTimeService.dateFormatShort, dateTimeService.timeFormatSeconds, dateStarted.getFullYear(), dateStarted.getMonth()+1, dateStarted.getDate(), dateStarted.getHours(), dateStarted.getMinutes(), dateStarted.getSeconds()); dateStarted.getFullYear(),
dateStarted.getMonth() + 1,
dateStarted.getDate(),
dateStarted.getHours(),
dateStarted.getMinutes(),
dateStarted.getSeconds());
dateStartedField.setAttribute("value", dateStarted); dateStartedField.setAttribute("value", dateStarted);
}
catch (e) {
}
try { var dateEnded = new Date(stmt.getInt64(1) / 1000);
var dateEnded = stmt.getInt64(1); dateEnded = dts.FormatDateTime("", dts.dateFormatShort,
dateEnded = new Date(dateEnded/1000); dts.timeFormatSeconds,
dateEnded = dateTimeService.FormatDateTime("", dateTimeService.dateFormatShort, dateTimeService.timeFormatSeconds, dateEnded.getFullYear(), dateEnded.getMonth()+1, dateEnded.getDate(), dateEnded.getHours(), dateEnded.getMinutes(), dateEnded.getSeconds()); dateEnded.getFullYear(),
dateEnded.getMonth() + 1,
dateEnded.getDate(),
dateEnded.getHours(),
dateEnded.getMinutes(),
dateEnded.getSeconds());
dateEndedField.setAttribute("value", dateEnded); dateEndedField.setAttribute("value", dateEnded);
}
catch (e) {
}
pathField.value = stmt.getUTF8String(2); pathField.value = stmt.getUTF8String(2);
sourceField.value = stmt.getUTF8String(3); sourceField.value = stmt.getUTF8String(3);
stmt.reset(); stmt.reset();
try { var dl = dm.getDownload(dlid);
window.opener.gDownloadManager.getDownload(dlid); if (dl.state == dlmgrIID.DOWNLOAD_DOWNLOADING ||
} catch (e) { // Download is not currently active dl.state == dlmgrIID.DOWNLOAD_PAUSED ||
dl.state == dlmgrIID.DOWNLOAD_NOTSTARTED) {
document.getElementById("dateEndedRow").hidden = true; document.getElementById("dateEndedRow").hidden = true;
document.getElementById("dateEndedSeparator").hidden = true; document.getElementById("dateEndedSeparator").hidden = true;
} }