Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes
calDateTime Class Reference

#include <calDateTime.h>

Inheritance diagram for calDateTime:
Inheritance graph
[legend]
Collaboration diagram for calDateTime:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 calDateTime ()
 calDateTime (icaltimetype const *icalt, calITimezone *tz)
void makeImmutable ()
 Make this calIDateTime instance immutable.
calIDateTime clone ()
 Clone this calIDateTime instance into a new mutable object.
void resetTo (in short year, in short month, in short day, in short hour, in short minute, in short second, in calITimezone timezone)
 Resets the datetime object.
void reset ()
 Resets this instance to Jan 1, 1970 00:00:00 UTC.
AUTF8String toString ()
 Return a string representation of this instance.
void setTimeInTimezone (in PRTime aTime, in calITimezone aTimezone)
 Set the value of this calIDateTime instance to aTime milliseconds since the epoch in the given timezone.
calIDateTime getInTimezone (in calITimezone aTimezone)
 Return a new calIDateTime instance that's the result of converting this one into the given timezone.
void addDuration (in calIDuration aDuration)
calIDuration subtractDate (in calIDateTime aOtherDate)
long compare (in calIDateTime aOther)
 Compare this calIDateTime instance to aOther.
void toIcalTime (in icaltimetypeptr itt)
void preCreate (in nsISupports nativeObj, in JSContextPtr cx, in JSObjectPtr globalObj, out JSObjectPtr parentObj)
void create (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj)
void postCreate (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj)
PRBool addProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp)
PRBool delProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp)
PRBool getProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp)
PRBool setProperty (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in JSValPtr vp)
PRBool enumerate (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj)
PRBool newEnumerate (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 enum_op, in JSValPtr statep, out JSID idp)
PRBool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in PRUint32 flags, out JSObjectPtr objp)
PRBool convert (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 type, in JSValPtr vp)
void finalize (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj)
PRBool checkAccess (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal id, in PRUint32 mode, in JSValPtr vp)
PRBool call (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 argc, in JSValPtr argv, in JSValPtr vp)
PRBool construct (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in PRUint32 argc, in JSValPtr argv, in JSValPtr vp)
PRBool hasInstance (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal val, out PRBool bp)
PRUint32 mark (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in voidPtr arg)
PRBool equality (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in JSVal val)
JSObjectPtr outerObject (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj)
JSObjectPtr innerObject (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj)

Public Attributes

readonly attribute boolean isMutable
 isMutable is true if this instance is modifiable.
readonly attribute boolean isValid
 valid is true if this object contains a valid time/date.
attribute PRTime nativeTime
 nativeTime contains this instance's PRTime value relative to the UTC epoch, regardless of the timezone that's set on this instance.
attribute short year
 Full 4-digit year value (e.g.
attribute short month
 Month, 0-11, 0 = January.
attribute short day
 Day of month, 1-[28,29,30,31].
attribute short hour
 Hour, 0-23.
attribute short minute
 Minute, 0-59.
attribute short second
 Second, 0-59.
attribute calITimezone timezone
 Gets or sets the timezone of this calIDateTime instance.
readonly attribute long timezoneOffset
 The offset of the timezone this datetime is in, relative to UTC, in seconds.
attribute PRBool isDate
 isDate indicates that this calIDateTime instance represents a date (a whole day), and not a specific time on that day.
readonly attribute short weekday
 Day of the week.
readonly attribute short yearday
 Day of the year, 1-[365,366].
readonly attribute calIDateTime startOfWeek
 Returns SUNDAY of the given datetime object's week.
readonly attribute calIDateTime endOfWeek
 Returns SATURDAY of the datetime object's week.
readonly attribute calIDateTime startOfMonth
readonly attribute calIDateTime endOfMonth
readonly attribute calIDateTime startOfYear
readonly attribute calIDateTime endOfYear
attribute ACString icalString
 This object as either an iCalendar DATE or DATETIME string, as appropriate and sets the timezone to either UTC or floating.
const PRUint32 WANT_PRECREATE = 1 << 0
const PRUint32 WANT_CREATE = 1 << 1
const PRUint32 WANT_POSTCREATE = 1 << 2
const PRUint32 WANT_ADDPROPERTY = 1 << 3
const PRUint32 WANT_DELPROPERTY = 1 << 4
const PRUint32 WANT_GETPROPERTY = 1 << 5
const PRUint32 WANT_SETPROPERTY = 1 << 6
const PRUint32 WANT_ENUMERATE = 1 << 7
const PRUint32 WANT_NEWENUMERATE = 1 << 8
const PRUint32 WANT_NEWRESOLVE = 1 << 9
const PRUint32 WANT_CONVERT = 1 << 10
const PRUint32 WANT_FINALIZE = 1 << 11
const PRUint32 WANT_CHECKACCESS = 1 << 12
const PRUint32 WANT_CALL = 1 << 13
const PRUint32 WANT_CONSTRUCT = 1 << 14
const PRUint32 WANT_HASINSTANCE = 1 << 15
const PRUint32 WANT_MARK = 1 << 16
const PRUint32 USE_JSSTUB_FOR_ADDPROPERTY = 1 << 17
const PRUint32 USE_JSSTUB_FOR_DELPROPERTY = 1 << 18
const PRUint32 USE_JSSTUB_FOR_SETPROPERTY = 1 << 19
const PRUint32 DONT_ENUM_STATIC_PROPS = 1 << 20
const PRUint32 DONT_ENUM_QUERY_INTERFACE = 1 << 21
const PRUint32 DONT_ASK_INSTANCE_FOR_SCRIPTABLE = 1 << 22
const PRUint32 CLASSINFO_INTERFACES_ONLY = 1 << 23
const PRUint32 ALLOW_PROP_MODS_DURING_RESOLVE = 1 << 24
const PRUint32 ALLOW_PROP_MODS_TO_PROTOTYPE = 1 << 25
const PRUint32 DONT_SHARE_PROTOTYPE = 1 << 26
const PRUint32 DONT_REFLECT_INTERFACE_NAMES = 1 << 27
const PRUint32 WANT_EQUALITY = 1 << 28
const PRUint32 WANT_OUTER_OBJECT = 1 << 29
const PRUint32 WANT_INNER_OBJECT = 1 << 30
const PRUint32 RESERVED = 1 << 31
readonly attribute string className
readonly attribute PRUint32 scriptableFlags

Protected Member Functions

void Normalize ()
 utility/protected methods
void FromIcalTime (icaltimetype const *icalt, calITimezone *tz)

Static Protected Member Functions

static PRTime IcaltimeToPRTime (icaltimetype const *icalt, icaltimezone const *tz)
static void PRTimeToIcaltime (PRTime time, PRBool isdate, icaltimezone const *tz, icaltimetype *icalt)

Protected Attributes

PRBool mImmutable
PRBool mIsValid
PRBool mIsDate
PRInt16 mYear
PRInt16 mMonth
PRInt16 mDay
PRInt16 mHour
PRInt16 mMinute
PRInt16 mSecond
PRInt16 mWeekday
PRInt16 mYearday
PRTime mNativeTime
nsCOMPtr< calITimezonemTimezone

Detailed Description

Definition at line 50 of file calDateTime.h.


Constructor & Destructor Documentation

Definition at line 66 of file calDateTime.cpp.

    : mImmutable(PR_FALSE)
{
    Reset();
}

Definition at line 72 of file calDateTime.cpp.

    : mImmutable(PR_FALSE)
{
    FromIcalTime(atimeptr, tz);
}

Here is the call graph for this function:


Member Function Documentation

void calIDateTime::addDuration ( in calIDuration  aDuration) [inherited]
PRBool nsIXPCScriptable::call ( in nsIXPConnectWrappedNative  wrapper,
in JSContextPtr  cx,
in JSObjectPtr  obj,
in PRUint32  argc,
in JSValPtr  argv,
in JSValPtr  vp 
) [inherited]

Clone this calIDateTime instance into a new mutable object.

long calIDateTime::compare ( in calIDateTime  aOther) [inherited]

Compare this calIDateTime instance to aOther.

Returns -1, 0, 1 to indicate if this < aOther, this == aOther, or this > aOther, respectively.

This comparison is timezone-aware; the given values are converted to a common timezone before comparing. If either this or aOther is floating, both objects are treated as floating for the comparison.

If either this or aOther has isDate set, then only the date portion is compared.

Exceptions:
calIErrors.INVALID_TIMEZONEbad timezone on this object (not the argument object)
PRBool nsIXPCScriptable::construct ( in nsIXPConnectWrappedNative  wrapper,
in JSContextPtr  cx,
in JSObjectPtr  obj,
in PRUint32  argc,
in JSValPtr  argv,
in JSValPtr  vp 
) [inherited]
void calDateTime::FromIcalTime ( icaltimetype const icalt,
calITimezone tz 
) [protected]

Definition at line 451 of file calDateTime.cpp.

{
    icaltimetype t = *icalt;
    mIsValid = (icaltime_is_null_time(t) ||
                icaltime_is_valid_time(t) ? PR_TRUE : PR_FALSE);

    mIsDate = t.is_date ? PR_TRUE : PR_FALSE;
    if (mIsDate) {
        t.hour = 0;
        t.minute = 0;
        t.second = 0;
    }

    if (mIsValid) {
        t = icaltime_normalize(t);
    }

    mYear = static_cast<PRInt16>(t.year);
    mMonth = static_cast<PRInt16>(t.month - 1);
    mDay = static_cast<PRInt16>(t.day);
    mHour = static_cast<PRInt16>(t.hour);
    mMinute = static_cast<PRInt16>(t.minute);
    mSecond = static_cast<PRInt16>(t.second);

    if (tz) {
        mTimezone = tz;
    } else {
        mTimezone = cal::detectTimezone(t, nsnull);
    }
#if defined(DEBUG)
    if (mTimezone) {
        if (t.is_utc) {
            NS_ASSERTION(SameCOMIdentity(mTimezone, cal::UTC()), "UTC mismatch!");
        } else if (!t.zone) {
            NS_ASSERTION(SameCOMIdentity(mTimezone, cal::floating()), "floating mismatch!");
        } else {
            nsCAutoString tzid;
            mTimezone->GetTzid(tzid);
            NS_ASSERTION(tzid.Equals(icaltimezone_get_tzid(const_cast<icaltimezone *>(t.zone))),
                         "tzid mismatch!");
        }
    }
#endif

    mWeekday = static_cast<PRInt16>(icaltime_day_of_week(t) - 1);
    mYearday = static_cast<PRInt16>(icaltime_day_of_year(t));

    // mNativeTime: not moving the existing date to UTC,
    // but merely representing it a UTC-based way.
    t.is_date = 0;
    mNativeTime = IcaltimeToPRTime(&t, icaltimezone_get_utc_timezone());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Return a new calIDateTime instance that's the result of converting this one into the given timezone.

Valid values for aTimezone are the same as the timezone field. If the "floating" timezone is given, then this object is just cloned, and the timezone is set to floating.

PRTime calDateTime::IcaltimeToPRTime ( icaltimetype const icalt,
icaltimezone const tz 
) [static, protected]

Definition at line 504 of file calDateTime.cpp.

{
    icaltimetype tt;
    PRExplodedTime et;

    /* If the time is the special null time, return 0. */
    if (icaltime_is_null_time(*icalt)) {
        return 0;
    }

    if (tz) {
        // use libical for timezone conversion, as it can handle all ics
        // timezones. having nspr do it is much harder.
        tt = icaltime_convert_to_zone(*icalt, const_cast<icaltimezone *>(tz));
    } else {
        tt = *icalt;
    }

    /* Empty the destination */
    memset(&et, 0, sizeof(struct PRExplodedTime));

    /* Fill the fields */
    if (icaltime_is_date(tt)) {
        et.tm_sec = et.tm_min = et.tm_hour = 0;
    } else {
        et.tm_sec = tt.second;
        et.tm_min = tt.minute;
        et.tm_hour = tt.hour;
    }
    et.tm_mday = static_cast<PRInt16>(tt.day);
    et.tm_month = static_cast<PRInt16>(tt.month-1);
    et.tm_year = static_cast<PRInt16>(tt.year);

    return PR_ImplodeTime(&et);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Make this calIDateTime instance immutable.

PRUint32 nsIXPCScriptable::mark ( in nsIXPConnectWrappedNative  wrapper,
in JSContextPtr  cx,
in JSObjectPtr  obj,
in voidPtr  arg 
) [inherited]
PRBool nsIXPCScriptable::newEnumerate ( in nsIXPConnectWrappedNative  wrapper,
in JSContextPtr  cx,
in JSObjectPtr  obj,
in PRUint32  enum_op,
in JSValPtr  statep,
out JSID  idp 
) [inherited]
void calDateTime::Normalize ( ) [protected]

utility/protected methods

Definition at line 421 of file calDateTime.cpp.

{
    icaltimetype icalt;
    ToIcalTime(&icalt);
    FromIcalTime(&icalt, mTimezone);
}

Here is the call graph for this function:

void nsIXPCScriptable::preCreate ( in nsISupports  nativeObj,
in JSContextPtr  cx,
in JSObjectPtr  globalObj,
out JSObjectPtr  parentObj 
) [inherited]
void calDateTime::PRTimeToIcaltime ( PRTime  time,
PRBool  isdate,
icaltimezone const tz,
icaltimetype icalt 
) [static, protected]

Definition at line 540 of file calDateTime.cpp.

{
    PRExplodedTime et;
    PR_ExplodeTime(time, PR_GMTParameters, &et);

    icalt->year   = et.tm_year;
    icalt->month  = et.tm_month + 1;
    icalt->day    = et.tm_mday;

    if (isdate) { 
        icalt->hour    = 0;
        icalt->minute  = 0;
        icalt->second  = 0;
        icalt->is_date = 1;
    } else {
        icalt->hour   = et.tm_hour;
        icalt->minute = et.tm_min;
        icalt->second = et.tm_sec;
        icalt->is_date = 0;
    }

    icalt->zone = tz;
    icalt->is_utc = ((tz && tz == icaltimezone_get_utc_timezone()) ? 1 : 0);
    icalt->is_daylight = 0;
    // xxx todo: discuss/investigate is_daylight
//     if (tz) {
//         icaltimezone_get_utc_offset(tz, icalt, &icalt->is_daylight);
//     }
}

Here is the call graph for this function:

void calIDateTime::reset ( ) [inherited]

Resets this instance to Jan 1, 1970 00:00:00 UTC.

void calIDateTime::resetTo ( in short  year,
in short  month,
in short  day,
in short  hour,
in short  minute,
in short  second,
in calITimezone  timezone 
) [inherited]

Resets the datetime object.

Parameters:
yearfull 4-digit year value (e.g. "1989", "2004")
monthmonth, 0-11, 0 = January
dayday of month, 1-[28,29,31]
hourhour, 0-23
minuteminute, 0-59
seconddecond, 0-59
timezonetimezone

The passed datetime will be normalized, e.g. a minute value of 60 will increase the hour.

Exceptions:
NS_ERROR_INVALID_ARGif no timezone is passed in.
void calIDateTime::setTimeInTimezone ( in PRTime  aTime,
in calITimezone  aTimezone 
) [inherited]

Set the value of this calIDateTime instance to aTime milliseconds since the epoch in the given timezone.

AUTF8String calIDateTime::toString ( ) [inherited]

Return a string representation of this instance.


Member Data Documentation

Definition at line 85 of file nsIXPCScriptable.idl.

Definition at line 86 of file nsIXPCScriptable.idl.

Definition at line 84 of file nsIXPCScriptable.idl.

Definition at line 98 of file nsIXPCScriptable.idl.

attribute short calIDateTime::day [inherited]

Day of month, 1-[28,29,30,31].

Definition at line 103 of file calIDateTime.idl.

Definition at line 83 of file nsIXPCScriptable.idl.

Definition at line 82 of file nsIXPCScriptable.idl.

Definition at line 81 of file nsIXPCScriptable.idl.

Definition at line 88 of file nsIXPCScriptable.idl.

Definition at line 87 of file nsIXPCScriptable.idl.

Definition at line 254 of file calIDateTime.idl.

Returns SATURDAY of the datetime object's week.

Definition at line 250 of file calIDateTime.idl.

Definition at line 258 of file calIDateTime.idl.

attribute short calIDateTime::hour [inherited]

Hour, 0-23.

Definition at line 108 of file calIDateTime.idl.

attribute ACString calIDateTime::icalString [inherited]

This object as either an iCalendar DATE or DATETIME string, as appropriate and sets the timezone to either UTC or floating.

Definition at line 266 of file calIDateTime.idl.

isDate indicates that this calIDateTime instance represents a date (a whole day), and not a specific time on that day.

If isDate is set, accessing the hour/minute/second fields will return 0, and and setting them is an illegal operation.

Definition at line 165 of file calIDateTime.idl.

isMutable is true if this instance is modifiable.

If isMutable is false, any attempts to modify the object will throw NS_ERROR_OBJECT_IS_IMMUTABLE.

Definition at line 53 of file calIDateTime.idl.

readonly attribute boolean calIDateTime::isValid [inherited]

valid is true if this object contains a valid time/date.

Definition at line 71 of file calIDateTime.idl.

Definition at line 69 of file calDateTime.h.

Definition at line 70 of file calDateTime.h.

Definition at line 63 of file calDateTime.h.

attribute short calIDateTime::minute [inherited]

Minute, 0-59.

Definition at line 113 of file calIDateTime.idl.

Definition at line 65 of file calDateTime.h.

Definition at line 64 of file calDateTime.h.

Definition at line 71 of file calDateTime.h.

Definition at line 68 of file calDateTime.h.

Definition at line 76 of file calDateTime.h.

attribute short calIDateTime::month [inherited]

Month, 0-11, 0 = January.

Definition at line 98 of file calIDateTime.idl.

Definition at line 72 of file calDateTime.h.

Definition at line 77 of file calDateTime.h.

Definition at line 73 of file calDateTime.h.

Definition at line 67 of file calDateTime.h.

Definition at line 74 of file calDateTime.h.

nativeTime contains this instance's PRTime value relative to the UTC epoch, regardless of the timezone that's set on this instance.

If nativeTime is set, the given UTC PRTime value is exploded into year/month/etc, taking into account the timezone setting.

Warning:
: When the timezone is set to 'floating', this will return the nativeTime as-if the timezone was UTC. Take this into account when comparing values.
Note:
on objects that are pinned to a timezone and have isDate set, nativeTime will be 00:00:00 in the timezone of that date, not 00:00:00 in UTC.

Definition at line 88 of file calIDateTime.idl.

const PRUint32 nsIXPCScriptable::RESERVED = 1 << 31 [inherited]

Definition at line 96 of file nsIXPCScriptable.idl.

Definition at line 99 of file nsIXPCScriptable.idl.

attribute short calIDateTime::second [inherited]

Second, 0-59.

Definition at line 118 of file calIDateTime.idl.

Definition at line 253 of file calIDateTime.idl.

Returns SUNDAY of the given datetime object's week.

Definition at line 245 of file calIDateTime.idl.

Definition at line 257 of file calIDateTime.idl.

Gets or sets the timezone of this calIDateTime instance.

Setting the timezone does not change the actual date/time components; to convert between timezones, use getInTimezone().

Exceptions:
NS_ERROR_INVALID_ARGif null is passed in.

Definition at line 127 of file calIDateTime.idl.

The offset of the timezone this datetime is in, relative to UTC, in seconds.

A positive number means that the timezone is ahead of UTC.

Definition at line 157 of file calIDateTime.idl.

Definition at line 78 of file nsIXPCScriptable.idl.

Definition at line 79 of file nsIXPCScriptable.idl.

Definition at line 80 of file nsIXPCScriptable.idl.

Definition at line 64 of file nsIXPCScriptable.idl.

Definition at line 74 of file nsIXPCScriptable.idl.

Definition at line 73 of file nsIXPCScriptable.idl.

Definition at line 75 of file nsIXPCScriptable.idl.

Definition at line 71 of file nsIXPCScriptable.idl.

Definition at line 62 of file nsIXPCScriptable.idl.

Definition at line 65 of file nsIXPCScriptable.idl.

Definition at line 68 of file nsIXPCScriptable.idl.

Definition at line 89 of file nsIXPCScriptable.idl.

Definition at line 72 of file nsIXPCScriptable.idl.

Definition at line 66 of file nsIXPCScriptable.idl.

Definition at line 76 of file nsIXPCScriptable.idl.

Definition at line 91 of file nsIXPCScriptable.idl.

Definition at line 77 of file nsIXPCScriptable.idl.

Definition at line 69 of file nsIXPCScriptable.idl.

Definition at line 70 of file nsIXPCScriptable.idl.

Definition at line 90 of file nsIXPCScriptable.idl.

Definition at line 63 of file nsIXPCScriptable.idl.

Definition at line 61 of file nsIXPCScriptable.idl.

Definition at line 67 of file nsIXPCScriptable.idl.

readonly attribute short calIDateTime::weekday [inherited]

Day of the week.

0-6, with Sunday = 0.

Definition at line 174 of file calIDateTime.idl.

attribute short calIDateTime::year [inherited]

Full 4-digit year value (e.g.

"1989", "2004")

Definition at line 93 of file calIDateTime.idl.

readonly attribute short calIDateTime::yearday [inherited]

Day of the year, 1-[365,366].

Definition at line 179 of file calIDateTime.idl.


The documentation for this class was generated from the following files: