Closed Bug 297827 Opened 20 years ago Closed 20 years ago

need calIDuration

Categories

(Calendar :: Internal Components, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: pavlov, Assigned: pavlov)

Details

Attachments

(1 file, 1 obsolete file)

We need a calIDuration for expressing things that aren't really dates.  We also
need them for alarms which need to be able to express ical duration strings...
Attached patch patch to add calIDuration and to start using it (obsolete) — — Splinter Review
Attachment #186392 - Flags: second-review?(shaver)
Attachment #186392 - Flags: first-review?(vladimir)
in calEvent.js's duration getter it should be:
  |return this.endDate.subtract(this.startDate);|
instead of whats in the patch
Comment on attachment 186392 [details] [diff] [review]
patch to add calIDuration and to start using it

>+  // Subtract two dates and return a duration
>+  calIDuration subtractDate (in calIDateTime aOtherDate);

It's not clear from this name or comment which way the subtraction
happens.  How would you feel about

// Compute the time from this dateTime to otherDT and return it as
// a calIDuration.  The duration will be negative if otherDT is
// before this.
calIDuration durationUntil(in calIDateTime otherDT);

?

>+  /**
>+   * This object as either an iCalendar DURATION string
>+   */
>+  readonly attribute ACString icalString;
>+};

...an iCalendar DURATION string or...?


>+    nsCOMPtr<calIDuration> result(do_CreateInstance("@mozilla.org/calendar/duration;1"));

OOM check?  (You could also just call |new| here, since it's a closed system,
if you wanted.)

r=shaver
Attachment #186392 - Flags: second-review?(shaver) → second-review+
I added the comments/oom checks you suggested shaver.  I left the method as
subtractDate but commented it better.

I also added an addDuration method on calIDuration that would add two durations
together and normalize the result.  I've also added a normalize function to the
interface just incase anyone wants it.

I added an attribute |inSeconds| that you can get/set the duration in seconds
with.

Someone should check my math in SetInSeconds() to make sure its right as well.
Attachment #186392 - Attachment is obsolete: true
Attachment #186407 - Flags: second-review?(shaver)
Attachment #186407 - Flags: first-review?(vladimir)
Attachment #186392 - Flags: second-review+
Attachment #186392 - Flags: first-review?(vladimir)
Comment on attachment 186407 [details] [diff] [review]
Updated with shaver's comments and new functions

r=me, go go go
Attachment #186407 - Flags: first-review?(vladimir) → first-review+
Comment on attachment 186407 [details] [diff] [review]
Updated with shaver's comments and new functions

2r=shaver, thx
Attachment #186407 - Flags: second-review?(shaver)
Attachment #186407 - Flags: second-review+
Attachment #186407 - Flags: first-review?(vladimir)
Attachment #186407 - Flags: first-review+
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Attachment #186407 - Flags: first-review?(vladimir)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: