зеркало из https://github.com/mozilla/gecko-dev.git
some datetime fixes
This commit is contained in:
Родитель
c230c4be03
Коммит
2f53fa9249
|
@ -59,16 +59,18 @@ interface calIDateTime : nsISupports
|
||||||
|
|
||||||
// this thing's base PRTime value, either as UTC or as timezoneless-
|
// this thing's base PRTime value, either as UTC or as timezoneless-
|
||||||
// local. Setting this will explode the PRTime value to year/etc
|
// local. Setting this will explode the PRTime value to year/etc
|
||||||
// based on the current value of timezoneOffset.
|
// based on the current value of timezone. PRTime is milliseconds
|
||||||
|
// since the epoch, in UTC.
|
||||||
attribute PRTime nativeTime;
|
attribute PRTime nativeTime;
|
||||||
|
|
||||||
|
//
|
||||||
// Year, fully exploded (e.g. "1989", "2004")
|
// Year, fully exploded (e.g. "1989", "2004")
|
||||||
attribute short year;
|
attribute short year;
|
||||||
|
|
||||||
// Month, 0-11
|
// Month, 0-11
|
||||||
attribute short month;
|
attribute short month;
|
||||||
|
|
||||||
// Day, 1 through whatever XXX - does libical want 1.. or 0..?
|
// Day, 1-[28,29,31]
|
||||||
attribute short day;
|
attribute short day;
|
||||||
|
|
||||||
// Hour, 0-23
|
// Hour, 0-23
|
||||||
|
@ -80,22 +82,19 @@ interface calIDateTime : nsISupports
|
||||||
// Second, 0-59
|
// Second, 0-59
|
||||||
attribute short second;
|
attribute short second;
|
||||||
|
|
||||||
// whether this thing indicates a time in UTC, or in the local time
|
// isUtc and tiemzone together specify the timezone of this file;
|
||||||
// zone
|
// - if isUtc is true, timezone is ignored and this datetime is UTC.
|
||||||
|
// - if isUtc is false and timezone is not null, then this datetime
|
||||||
|
// is in the given timezone
|
||||||
|
// - if isUtc is false and timezone is null, then this datetime
|
||||||
|
// represents a floating time; the actual nativeTime representation
|
||||||
|
// will still be as if it was in UTC
|
||||||
attribute PRBool isUtc;
|
attribute PRBool isUtc;
|
||||||
|
|
||||||
// if true, this calIDateTime represents a date (whole day), not a
|
|
||||||
// specific second
|
|
||||||
attribute PRBool isDate;
|
|
||||||
|
|
||||||
// an associated timezone that's the preferred way of representing
|
|
||||||
// this object. If this is null/empty, then there is no preferred
|
|
||||||
// timezone, and UTC or localtime is assumed (based on isUtc). If
|
|
||||||
// this is non-null when assigned, isUtc is automatically cleared.
|
|
||||||
attribute AUTF8String timezone;
|
attribute AUTF8String timezone;
|
||||||
|
|
||||||
// the offset in minutes from UTC that this date is stored in.
|
// if true, this calIDateTime represents a date (whole day), not a
|
||||||
attribute PRInt32 timezoneOffset;
|
// specific hour/minute/second
|
||||||
|
attribute PRBool isDate;
|
||||||
|
|
||||||
//
|
//
|
||||||
// computed values
|
// computed values
|
||||||
|
@ -161,6 +160,12 @@ interface calIDateTime : nsISupports
|
||||||
readonly attribute ACString icalString;
|
readonly attribute ACString icalString;
|
||||||
|
|
||||||
/* JS only:
|
/* JS only:
|
||||||
|
* // Setting jsDate via a JavaScript Date object will set
|
||||||
|
* // the calIDateTime to the jsDate's time ***in UTC***.
|
||||||
|
* // There's no way for us to recover TZ info from a jsDate,
|
||||||
|
* // so we always pull it out as UTC, and force the calIDateTime's
|
||||||
|
* // timezone to UTC.
|
||||||
* attribute Date jsDate;
|
* attribute Date jsDate;
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
|
@ -141,7 +141,6 @@ calDateTime::Reset()
|
||||||
mIsUtc = PR_FALSE;
|
mIsUtc = PR_FALSE;
|
||||||
mWeekday = 0;
|
mWeekday = 0;
|
||||||
mYearday = 0;
|
mYearday = 0;
|
||||||
mTimezoneOffset = 0;
|
|
||||||
mIsDate = PR_FALSE;
|
mIsDate = PR_FALSE;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -157,7 +156,6 @@ CAL_VALUETYPE_ATTR(calDateTime, PRInt16, Minute)
|
||||||
CAL_VALUETYPE_ATTR(calDateTime, PRInt16, Second)
|
CAL_VALUETYPE_ATTR(calDateTime, PRInt16, Second)
|
||||||
CAL_VALUETYPE_ATTR(calDateTime, PRBool, IsUtc)
|
CAL_VALUETYPE_ATTR(calDateTime, PRBool, IsUtc)
|
||||||
CAL_VALUETYPE_ATTR(calDateTime, PRBool, IsDate)
|
CAL_VALUETYPE_ATTR(calDateTime, PRBool, IsDate)
|
||||||
CAL_VALUETYPE_ATTR(calDateTime, PRInt32, TimezoneOffset)
|
|
||||||
|
|
||||||
CAL_VALUETYPE_ATTR_GETTER(calDateTime, PRInt16, Weekday)
|
CAL_VALUETYPE_ATTR_GETTER(calDateTime, PRInt16, Weekday)
|
||||||
CAL_VALUETYPE_ATTR_GETTER(calDateTime, PRInt16, Yearday)
|
CAL_VALUETYPE_ATTR_GETTER(calDateTime, PRInt16, Yearday)
|
||||||
|
@ -296,7 +294,7 @@ calDateTime::GetInTimezone(const char *aTimezone, calIDateTime **aResult)
|
||||||
|
|
||||||
ToIcalTime(&icalt);
|
ToIcalTime(&icalt);
|
||||||
|
|
||||||
if (!aTimezone) {
|
if (!aTimezone || strcmp(aTimezone, "UTC") == 0 || strcmp(aTimezone, "utc") == 0) {
|
||||||
destzone = icaltimezone_get_utc_timezone();
|
destzone = icaltimezone_get_utc_timezone();
|
||||||
} else {
|
} else {
|
||||||
nsCOMPtr<calIICSService> ics = do_GetService(kCalICSService);
|
nsCOMPtr<calIICSService> ics = do_GetService(kCalICSService);
|
||||||
|
@ -596,22 +594,9 @@ calDateTime::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
|
||||||
LL_MUL(utcTime, utcTime, thousands);
|
LL_MUL(utcTime, utcTime, thousands);
|
||||||
|
|
||||||
mIsUtc = PR_TRUE;
|
mIsUtc = PR_TRUE;
|
||||||
|
mTimezone.Truncate();
|
||||||
jsval tzoffsetval;
|
|
||||||
if (!JS_CallFunctionName(cx, dobj, "getTimezoneOffset", 0, nsnull, &tzoffsetval)) {
|
|
||||||
mValid = PR_FALSE;
|
|
||||||
} else {
|
|
||||||
JS_ValueToECMAInt32(cx, tzoffsetval, (int32*)&mTimezoneOffset);
|
|
||||||
mTimezone.AssignLiteral("");
|
|
||||||
nsresult rv = SetNativeTime(utcTime);
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
mValid = PR_FALSE;
|
|
||||||
} else {
|
|
||||||
mValid = PR_TRUE;
|
mValid = PR_TRUE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*_retval = PR_TRUE;
|
*_retval = PR_TRUE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "calIDateTime.h"
|
#include "calIDateTime.h"
|
||||||
|
|
||||||
struct icaltimetype;
|
struct icaltimetype;
|
||||||
|
struct _icaltimezone;
|
||||||
|
|
||||||
class calDateTime : public calIDateTime,
|
class calDateTime : public calIDateTime,
|
||||||
public nsIXPCScriptable
|
public nsIXPCScriptable
|
||||||
|
@ -81,12 +82,12 @@ protected:
|
||||||
PRBool mIsUtc;
|
PRBool mIsUtc;
|
||||||
PRBool mIsDate;
|
PRBool mIsDate;
|
||||||
nsCString mTimezone;
|
nsCString mTimezone;
|
||||||
PRInt32 mTimezoneOffset;
|
|
||||||
|
|
||||||
PRInt16 mWeekday;
|
PRInt16 mWeekday;
|
||||||
PRInt16 mYearday;
|
PRInt16 mYearday;
|
||||||
|
|
||||||
void FromIcalTime(icaltimetype *icalt);
|
void FromIcalTime(icaltimetype *icalt);
|
||||||
|
struct _icaltimezone* GetIcalTZ(const nsACString& tzid);
|
||||||
|
|
||||||
PRTime mLastModified;
|
PRTime mLastModified;
|
||||||
};
|
};
|
||||||
|
|
Загрузка…
Ссылка в новой задаче