fix bug #40380. get date searches and date filters to work.

preflight the date picker with today's date.

there is no date picker yet, but there is a simple xul textbox.
d/m/yyyy is the supported format.  there are plans to implement
a date picker in XBL which prevent user error.  right now, a user
could type "foobar" for the date.

r=timeless, sr=bienveu
This commit is contained in:
sspitzer%netscape.com 2001-07-11 07:52:13 +00:00
Родитель 2ff63310ec
Коммит a5a2e94fba
2 изменённых файлов: 42 добавлений и 1 удалений

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

@ -181,7 +181,7 @@
}
// now restore the selection
menulist.selectedItem = newSelection
menulist.selectedItem = newSelection;
]]>
</body>
</method>
@ -286,6 +286,7 @@
<xul:menuitem value ="65536" stringTag="forwarded" class="search-value-menuitem"/>
</xul:menupopup>
</xul:menulist>
<xul:textbox flex="1" class="search-value-textbox"/>
</content>
<implementation>
<property name="internalAttribute">null</property>
@ -305,6 +306,8 @@
this.setAttribute("index", "1");
else if (val == Components.interfaces.nsMsgSearchAttrib.MsgStatus)
this.setAttribute("index", "2");
else if (val == Components.interfaces.nsMsgSearchAttrib.Date)
this.setAttribute("index", "3");
else
this.setAttribute("index", "0");
return val;
@ -334,6 +337,8 @@
}
else if (attrib == nsMsgSearchAttrib.AgeInDays)
children[0].value = val.age;
else if (attrib == nsMsgSearchAttrib.Date)
children[3].value = convertPRTimeToString(val.date);
else
children[0].value = val.str;
return val;
@ -356,6 +361,8 @@
searchValue.status = children[2].selectedItem.value;
else if (searchAttribute == nsMsgSearchAttrib.AgeInDays)
searchValue.age = children[0].value;
else if (searchAttribute == nsMsgSearchAttrib.Date)
searchValue.date = convertStringToPRTime(children[3].value);
else
searchValue.str = children[0].value;
]]>
@ -394,6 +401,11 @@
var bundle = srGetStrBundle("chrome://messenger/locale/messenger.properties");
this.fillStringsForChildren(document.getAnonymousNodes(this)[1].firstChild, bundle);
this.fillStringsForChildren(document.getAnonymousNodes(this)[2].firstChild, bundle);
// preflight the date picker to today's date
var datePicker = document.getAnonymousNodes(this)[3];
var time = new Date();
datePicker.setAttribute("value",convertDateToString(time));
]]>
</constructor>
</implementation>

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

@ -382,3 +382,32 @@ function onReset(event)
removeSearchRow(--gTotalSearchTerms);
onMore(event);
}
function convertPRTimeToString(tm)
{
var time = new Date();
// PRTime is in microseconds, Javascript time is in seconds
// so divide by 1000 when converting
time.setTime(tm / 1000);
return convertDateToString(time);
}
function convertDateToString(time)
{
var dateStr = time.getMonth() + 1;
dateStr += "/";
dateStr += time.getDate();
dateStr += "/";
dateStr += 1900 + time.getYear();
return dateStr;
}
function convertStringToPRTime(str)
{
var time = new Date();
time.setTime(Date.parse(str));
// Javascript time is in seconds, PRTime is in microseconds
// so multiply by 1000 when converting
return (time.getTime() * 1000);
}