/* -*- Mode: idl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

[scriptable, uuid(78537f21-fd5c-4e02-ab26-8ff6a3d946cb)]
interface calIDuration : 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 calIDuration instance immutable.
   */
  void makeImmutable();

  /**
   * Clone this calIDuration instance into a new
   * mutable object.
   */
  calIDuration clone();

  /**
   * Is Negative
   */
  attribute boolean isNegative;

  /**
   * Weeks
   */
  attribute short weeks;

  /**
   * Days
   */
  attribute short days;

  /**
   * Hours
   */
  attribute short hours;

  /**
   * Minutes
   */
  attribute short minutes;

  /**
   * Seconds
   */
  attribute short seconds;

  /**
   * total duration in seconds
   */
  attribute long inSeconds;

  /*
   * Methods
   */

  /**
   * Add a duration
   */
  void addDuration(in calIDuration aDuration);

  /**
   * Compare with another duration
   *
   * @param    aOther     to be compared with this object
   * 
   * @return   -1, 0, 1 if this < aOther, this == aOther, or this > aOther,
   *           respectively.
   */
  long compare(in calIDuration aOther);

  /**
   * Reset this duration to 0
   */
  void reset();

  /**
   * Normalize the duration
   */
  void normalize();

  /**
   * Return a string representation of this instance.
   */
  AUTF8String toString();

  attribute jsval icalDuration;

  /**
   * This object as an iCalendar DURATION string
   */
  attribute ACString icalString;
};

/** Libical specific interfaces */

[ptr] native icaldurationtypeptr(struct icaldurationtype);
[scriptable, uuid(f5e1c987-e722-4dec-bf91-93d4062b504a)]
interface calIDurationLibical : calIDuration
{
  [noscript,notxpcom] void toIcalDuration(in icaldurationtypeptr idt);
};
