mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Disabling daylight saving time for years before 1970 in the backend. ( Fixes bug 155442 )
This commit is contained in:
parent
07ba2589b3
commit
0450be6a32
@ -123,6 +123,11 @@ function TestAll()
|
||||
gTodoObserver = new Observer();
|
||||
iCalLib.addTodoObserver( gTodoObserver );
|
||||
}
|
||||
if( !TestTimeConversion() ) {
|
||||
alert( "Stopped Test" );
|
||||
return;
|
||||
}
|
||||
|
||||
iCalLib.setServer( DEFAULT_SERVER );
|
||||
var id = TestAddEvent();
|
||||
if( id == 0 ) {
|
||||
@ -148,6 +153,52 @@ function TestAll()
|
||||
alert( "Finished Test" );
|
||||
}
|
||||
|
||||
function TestTimeConversion() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var dateTimeComponent = Components.classes["@mozilla.org/oedatetime;1"].createInstance();
|
||||
dateTime = dateTimeComponent.QueryInterface(Components.interfaces.oeIDateTime);
|
||||
var date1 = new Date();
|
||||
dateTime.setTime( date1 );
|
||||
var date1inms = parseInt( date1.getTime()/1000 );
|
||||
if( (dateTime.getTime()/1000) != date1inms ) {
|
||||
alert( "TestTimeConversion(): Step1 failed" );
|
||||
return false;
|
||||
}
|
||||
date1 = new Date( 1970, 0, 1, 0, 0, 0 );
|
||||
dateTime.setTime( date1 );
|
||||
date1inms = parseInt( date1.getTime()/1000 );
|
||||
if( (dateTime.getTime()/1000) != date1inms ) {
|
||||
alert( "TestTimeConversion(): Step2 failed" );
|
||||
return false;
|
||||
}
|
||||
date1 = new Date( 1969, 11, 31, 23, 59, 59 );
|
||||
dateTime.setTime( date1 );
|
||||
date1inms = parseInt( date1.getTime()/1000 );
|
||||
if( (dateTime.getTime()/1000) != date1inms ) {
|
||||
alert( "TestTimeConversion(): Step3 failed" );
|
||||
return false;
|
||||
}
|
||||
date1 = new Date( 1969, 11, 31, 19, 0, 0 );
|
||||
dateTime.setTime( date1 );
|
||||
date1inms = parseInt( date1.getTime()/1000 );
|
||||
if( (dateTime.getTime()/1000) != date1inms ) {
|
||||
alert( "TestTimeConversion(): Step4 failed" );
|
||||
return false;
|
||||
}
|
||||
date1 = new Date( 1962, 7, 03, 0, 0, 0 );
|
||||
dateTime.setTime( date1 );
|
||||
date1inms = parseInt( date1.getTime()/1000 );
|
||||
if( (dateTime.getTime()/1000) != date1inms ) {
|
||||
alert( "TestTimeConversion(): Step5 failed" );
|
||||
return false;
|
||||
}
|
||||
if( dateTime.hour != date1.getHours() ) {
|
||||
alert( "TestTimeConversion(): Step6 failed" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function TestAddEvent()
|
||||
{
|
||||
var iCalEventComponent = Components.classes["@mozilla.org/icalevent;1"].createInstance();
|
||||
|
@ -153,7 +153,7 @@ NS_IMETHODIMP oeDateTimeImpl::GetTime(PRTime *retval)
|
||||
NS_IMETHODIMP oeDateTimeImpl::ToString(char **retval)
|
||||
{
|
||||
char tmp[20];
|
||||
sprintf( tmp, "%04d/%02d/%02d %02d:%02d:%02d" , m_datetime.year, m_datetime.month, m_datetime.day, m_datetime.hour, m_datetime.minute, 0 );
|
||||
sprintf( tmp, "%04d/%02d/%02d %02d:%02d:%02d" , m_datetime.year, m_datetime.month, m_datetime.day, m_datetime.hour, m_datetime.minute, m_datetime.second );
|
||||
*retval= (char*) nsMemory::Clone( tmp, strlen(tmp)+1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ icaltimetype ConvertFromPrtime( PRTime indate ) {
|
||||
outdate.hour = ext.tm_hour;
|
||||
outdate.minute = ext.tm_min;
|
||||
outdate.second = ext.tm_sec;
|
||||
if( ext.tm_year <= 1969 && ext.tm_params.tp_dst_offset == 3600 )//Assume that daylight time saving was not in effect before 1970
|
||||
icaltime_adjust( &outdate, 0, -1, 0, 0 );
|
||||
|
||||
return outdate;
|
||||
}
|
||||
@ -91,6 +93,8 @@ PRTime ConvertToPrtime ( icaltimetype indate ) {
|
||||
|
||||
PRTime result = PR_ImplodeTime( &ext );
|
||||
PR_ExplodeTime( result, PR_LocalTimeParameters, &ext);
|
||||
if( ext.tm_year <= 1969 && ext.tm_params.tp_dst_offset == 3600 ) //Assume that daylight time saving was not in effect before 1970
|
||||
ext.tm_params.tp_dst_offset = 0;
|
||||
ext.tm_year = indate.year;
|
||||
ext.tm_month = indate.month - 1;
|
||||
ext.tm_mday = indate.day;
|
||||
|
Loading…
Reference in New Issue
Block a user