/* -*- 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"

[ptr] native icaldurationtypeptr(struct icaldurationtype);

[scriptable, uuid(d1d2e05d-5472-482e-b0a4-a9e43925d530)]
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();

  [noscript,notxpcom] void toIcalDuration(in icaldurationtypeptr idt);

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