mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 15:15:23 +00:00
264 lines
7.9 KiB
Plaintext
264 lines
7.9 KiB
Plaintext
/* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
*
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
* http://www.mozilla.org/MPL/
|
|
*
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
* for the specific language governing rights and limitations under the
|
|
* License.
|
|
*
|
|
* The Original Code is Oracle Corporation code.
|
|
*
|
|
* The Initial Developer of the Original Code is
|
|
* Oracle Corporation
|
|
* Portions created by the Initial Developer are Copyright (C) 2004
|
|
* the Initial Developer. All Rights Reserved.
|
|
*
|
|
* Contributor(s):
|
|
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
|
|
* Dan Mosedale <dan.mosedale@oracle.com>
|
|
*
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
* the provisions above, a recipient may use your version of this file under
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
*
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
interface calIDuration;
|
|
[ptr] native icaltimetypeptr(struct icaltimetype);
|
|
|
|
[scriptable, uuid(5678d4a3-2543-4ece-afbb-079292f2866e)]
|
|
interface calIDateTime : nsISupports
|
|
{
|
|
/**
|
|
* isMutable is true if this instance is modifiable.
|
|
* If isMutable is false, any attempts to modify
|
|
* the object will throw CAL_ERROR_ITEM_IS_MUTABLE.
|
|
*/
|
|
readonly attribute boolean isMutable;
|
|
|
|
/**
|
|
* Make this calIDateTime instance immutable.
|
|
*/
|
|
void makeImmutable();
|
|
|
|
/**
|
|
* Clone this calIDateTime instance into a new
|
|
* mutable object.
|
|
*/
|
|
calIDateTime clone();
|
|
|
|
/**
|
|
* valid is true if this object contains a valid
|
|
* time/date.
|
|
*/
|
|
// true if this thing is set/valid
|
|
readonly attribute boolean isValid;
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
attribute PRTime nativeTime;
|
|
|
|
/**
|
|
* Full 4-digit year value (e.g. "1989", "2004")
|
|
*/
|
|
attribute short year;
|
|
|
|
/**
|
|
* Month, 0-11, 0 = January
|
|
*/
|
|
attribute short month;
|
|
|
|
/**
|
|
* Day of month, 1-[28,29,31]
|
|
*/
|
|
attribute short day;
|
|
|
|
/**
|
|
* Hour, 0-23
|
|
*/
|
|
attribute short hour;
|
|
|
|
/**
|
|
* Minute, 0-59
|
|
*/
|
|
attribute short minute;
|
|
|
|
/**
|
|
* Second, 0-59
|
|
*/
|
|
attribute short second;
|
|
|
|
/**
|
|
* 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().
|
|
*
|
|
* Valid values are:
|
|
*
|
|
* - "UTC" (or "utc", "UTC" preferred)
|
|
* - the object refers to a time in UTC.
|
|
* - a TZID string, understood by the ICS Service
|
|
* - the object refers to a time in that tz
|
|
* - "floating"
|
|
* - the object is in floating time and does not have an
|
|
* associated timezone.
|
|
*
|
|
* @throws NS_ERROR_INVALID_ARG if an invalid timezone is passed in.
|
|
*/
|
|
attribute AUTF8String timezone;
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
readonly attribute long timezoneOffset;
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
attribute PRBool isDate;
|
|
|
|
/*
|
|
* computed values
|
|
*/
|
|
|
|
/**
|
|
* Day of the week. 0-6, with Sunday = 0.
|
|
*/
|
|
readonly attribute short weekday;
|
|
|
|
/**
|
|
* Day of the year, 0-365/366.
|
|
*/
|
|
readonly attribute short yearday;
|
|
|
|
/*
|
|
* Methods
|
|
*/
|
|
|
|
/**
|
|
* Reset this instance to an invalid state.
|
|
*/
|
|
void reset();
|
|
|
|
/**
|
|
* Return a string representation of this instance.
|
|
*/
|
|
AUTF8String toString();
|
|
|
|
// normalize and validate the expanded-out values
|
|
// XXX going away soon
|
|
void normalize();
|
|
|
|
/**
|
|
* Set the value of this calIDateTime instance
|
|
* to aTime milliseconds since the epoch in the
|
|
* given timezone. Valid values for the aTimezone
|
|
* are either a known TZID or "UTC"; null/empty string
|
|
* is not valid.
|
|
*/
|
|
void setTimeInTimezone (in PRTime aTime, in AUTF8String aTimezone);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
calIDateTime getInTimezone (in AUTF8String aTimezone);
|
|
|
|
// add the given calIDateTime, treating it as a duration, to
|
|
// this item.
|
|
// XXX will change
|
|
void addDuration (in calIDuration aDuration);
|
|
|
|
// Subtract two dates and return a duration
|
|
// returns duration of this - aOtherDate
|
|
// if aOtherDate is > this the duration will be negative
|
|
calIDuration subtractDate (in calIDateTime aOtherDate);
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @exception calIErrors.INVALID_TIMEZONE bad timezone on this object
|
|
* (not the argument object)
|
|
*/
|
|
long compare (in calIDateTime aOther);
|
|
|
|
//
|
|
// Some helper getters for calculating useful ranges
|
|
//
|
|
|
|
// the start/end of the current object's week
|
|
readonly attribute calIDateTime startOfWeek;
|
|
readonly attribute calIDateTime endOfWeek;
|
|
|
|
// the start/end of the current object's month
|
|
readonly attribute calIDateTime startOfMonth;
|
|
readonly attribute calIDateTime endOfMonth;
|
|
|
|
// the start/end of the current object's year
|
|
readonly attribute calIDateTime startOfYear;
|
|
readonly attribute calIDateTime endOfYear;
|
|
|
|
[noscript,notxpcom] void toIcalTime(in icaltimetypeptr itt);
|
|
|
|
/**
|
|
* This object as either an iCalendar DATE or DATETIME string, as
|
|
* appropriate.
|
|
*/
|
|
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;
|
|
*
|
|
*/
|
|
};
|