зеркало из https://github.com/mozilla/gecko-dev.git
Bug 502860 - some of the seventh month's history entries missing in grouped by date history, r=sdwilsh
Includes fix for Bug 501439 - History shows month-name 'March' for February
This commit is contained in:
Родитель
8fd52d3c13
Коммит
4ae2ce6fd5
|
@ -3563,9 +3563,9 @@ PlacesSQLQueryBuilder::SelectAsDay()
|
|||
// From start of epoch
|
||||
sqlFragmentContainerBeginTime = NS_LITERAL_CSTRING(
|
||||
"(datetime(0, 'unixepoch')*1000000)");
|
||||
// To start of 6 months ago
|
||||
// To start of 6 months ago ( 5 months + this month).
|
||||
sqlFragmentContainerEndTime = NS_LITERAL_CSTRING(
|
||||
"(strftime('%s','now','localtime','start of day','-6 months','utc')*1000000)");
|
||||
"(strftime('%s','now','localtime','start of month','-5 months','utc')*1000000)");
|
||||
// Search for the same timeframe.
|
||||
sqlFragmentSearchBeginTime = sqlFragmentContainerBeginTime;
|
||||
sqlFragmentSearchEndTime = sqlFragmentContainerEndTime;
|
||||
|
@ -3577,6 +3577,10 @@ PlacesSQLQueryBuilder::SelectAsDay()
|
|||
PRExplodedTime tm;
|
||||
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &tm);
|
||||
PRUint16 currentYear = tm.tm_year;
|
||||
// Set day before month, setting month without day could cause issues.
|
||||
// For example setting month to February when today is 30, since
|
||||
// February has not 30 days, will return March instead.
|
||||
tm.tm_mday = 1;
|
||||
tm.tm_month -= MonthIndex;
|
||||
PR_NormalizeTime(&tm, PR_LocalTimeParameters);
|
||||
// tm_month starts from 0 while GetMonthName expects a 1-based index.
|
||||
|
|
|
@ -82,6 +82,19 @@ function add_normalized_visit(aURI, aTime, aDayOffset) {
|
|||
return visitId;
|
||||
}
|
||||
|
||||
function days_for_x_months_ago(aNowObj, aMonths) {
|
||||
var oldTime = new Date();
|
||||
// Set day before month, otherwise we could try to calculate 30 February, or
|
||||
// other not existant days.
|
||||
oldTime.setDate(1);
|
||||
oldTime.setMonth(aNowObj.getMonth() - aMonths);
|
||||
oldTime.setHours(0);
|
||||
oldTime.setMinutes(0);
|
||||
oldTime.setSeconds(0);
|
||||
// Stay larger for eventual timezone issues, add 2 days.
|
||||
return parseInt((aNowObj - oldTime) / (1000*60*60*24)) + 2;
|
||||
}
|
||||
|
||||
var nowObj = new Date();
|
||||
// This test relies on en-US locale
|
||||
// Offset is number of days
|
||||
|
@ -90,8 +103,12 @@ var containers = [
|
|||
{ label: "Yesterday" , offset: -1 , visible: true },
|
||||
{ label: "Last 7 days" , offset: -3 , visible: true },
|
||||
{ label: "This month" , offset: -8 , visible: nowObj.getDate() > 8 },
|
||||
{ label: "" , offset: -nowObj.getDate()-1 , visible: true },
|
||||
{ label: "Older than 6 months" , offset: -nowObj.getDate()-186 , visible: true },
|
||||
{ label: "" , offset: -days_for_x_months_ago(nowObj, 0) , visible: true },
|
||||
{ label: "" , offset: -days_for_x_months_ago(nowObj, 1) , visible: true },
|
||||
{ label: "" , offset: -days_for_x_months_ago(nowObj, 2) , visible: true },
|
||||
{ label: "" , offset: -days_for_x_months_ago(nowObj, 3) , visible: true },
|
||||
{ label: "" , offset: -days_for_x_months_ago(nowObj, 4) , visible: true },
|
||||
{ label: "Older than 6 months" , offset: -days_for_x_months_ago(nowObj, 5) , visible: true },
|
||||
];
|
||||
|
||||
var visibleContainers = containers.filter(
|
||||
|
@ -130,12 +147,16 @@ function fill_history() {
|
|||
|
||||
var cc = root.childCount;
|
||||
print("Found containers:");
|
||||
var previousLabels = [];
|
||||
for (var i = 0; i < cc; i++) {
|
||||
var container = visibleContainers[i];
|
||||
var node = root.getChild(i);
|
||||
print(node.title);
|
||||
if (container.label)
|
||||
do_check_eq(node.title, container.label);
|
||||
// Check labels are not repeated.
|
||||
do_check_eq(previousLabels.indexOf(node.title), -1);
|
||||
previousLabels.push(node.title);
|
||||
}
|
||||
do_check_eq(cc, visibleContainers.length);
|
||||
root.containerOpen = false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче