diff --git a/calendar/base/public/calIDateTime.idl b/calendar/base/public/calIDateTime.idl index ffcb4e3de5d4..036add2791d9 100644 --- a/calendar/base/public/calIDateTime.idl +++ b/calendar/base/public/calIDateTime.idl @@ -59,16 +59,18 @@ interface calIDateTime : nsISupports // this thing's base PRTime value, either as UTC or as timezoneless- // 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; + // // Year, fully exploded (e.g. "1989", "2004") attribute short year; // Month, 0-11 attribute short month; - // Day, 1 through whatever XXX - does libical want 1.. or 0..? + // Day, 1-[28,29,31] attribute short day; // Hour, 0-23 @@ -80,22 +82,19 @@ interface calIDateTime : nsISupports // Second, 0-59 attribute short second; - // whether this thing indicates a time in UTC, or in the local time - // zone + // isUtc and tiemzone together specify the timezone of this file; + // - 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; - - // 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; - // the offset in minutes from UTC that this date is stored in. - attribute PRInt32 timezoneOffset; + // if true, this calIDateTime represents a date (whole day), not a + // specific hour/minute/second + attribute PRBool isDate; // // computed values @@ -161,6 +160,12 @@ interface calIDateTime : nsISupports readonly attribute ACString icalString; /* 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; + * */ }; diff --git a/calendar/base/src/calDateTime.cpp b/calendar/base/src/calDateTime.cpp index 138ff0fb4af0..f3357e6fd074 100644 --- a/calendar/base/src/calDateTime.cpp +++ b/calendar/base/src/calDateTime.cpp @@ -141,7 +141,6 @@ calDateTime::Reset() mIsUtc = PR_FALSE; mWeekday = 0; mYearday = 0; - mTimezoneOffset = 0; mIsDate = PR_FALSE; return NS_OK; @@ -157,7 +156,6 @@ CAL_VALUETYPE_ATTR(calDateTime, PRInt16, Minute) CAL_VALUETYPE_ATTR(calDateTime, PRInt16, Second) CAL_VALUETYPE_ATTR(calDateTime, PRBool, IsUtc) 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, Yearday) @@ -296,7 +294,7 @@ calDateTime::GetInTimezone(const char *aTimezone, calIDateTime **aResult) ToIcalTime(&icalt); - if (!aTimezone) { + if (!aTimezone || strcmp(aTimezone, "UTC") == 0 || strcmp(aTimezone, "utc") == 0) { destzone = icaltimezone_get_utc_timezone(); } else { nsCOMPtr ics = do_GetService(kCalICSService); @@ -596,21 +594,8 @@ calDateTime::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext * cx, LL_MUL(utcTime, utcTime, thousands); mIsUtc = PR_TRUE; - - 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; - } - } + mTimezone.Truncate(); + mValid = PR_TRUE; } *_retval = PR_TRUE; diff --git a/calendar/base/src/calDateTime.h b/calendar/base/src/calDateTime.h index 222c849c930c..67840467fe10 100644 --- a/calendar/base/src/calDateTime.h +++ b/calendar/base/src/calDateTime.h @@ -47,6 +47,7 @@ #include "calIDateTime.h" struct icaltimetype; +struct _icaltimezone; class calDateTime : public calIDateTime, public nsIXPCScriptable @@ -81,12 +82,12 @@ protected: PRBool mIsUtc; PRBool mIsDate; nsCString mTimezone; - PRInt32 mTimezoneOffset; PRInt16 mWeekday; PRInt16 mYearday; void FromIcalTime(icaltimetype *icalt); + struct _icaltimezone* GetIcalTZ(const nsACString& tzid); PRTime mLastModified; };