Closed Bug 198694 Opened 23 years ago Closed 21 years ago

Fix nsTime to handle nsInt64 operations better

Categories

(Core :: XPCOM, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha3

People

(Reporter: dwitte, Assigned: Biesinger)

Details

Attachments

(1 file)

currently, nsTime has limited arithmetic abilities, and doesn't inherit from nsInt64, so you can't do simple things like nsTime(foo) / nsTime(bar) or nsTime(foo) / nsInt64(bar) at the moment, these require horrible constructs like |nsInt64(nsTime(foo)) / nsInt64(nsTime(bar))| if you have two nsTimes. on a related topic, the types in prtime.h could use some extra helpers (-> wtc?). doing things like nsTime(foo) / PR_USEC_PER_SEC doesn't give you expected results, because the nsTime doesn't cast itself to anything except PRTime, a.k.a PRInt64. so it's most definitely not !HAS_LONG_LONG safe. since the PR_USEC_PER_SEC (and related) constants are defined as UL, you need to wrap them with nsInt64() (not nsTime(), because it can't cast from UL) to do "real" 64-bit ops. further, since they're UL, if you're compiling on a machine that defines "long" as 64-bit, then you're asking for a 64-bit unsigned ctor for nsInt64(), which doesn't exist. so these convenience classes aren't too convenient, when I end up having to do things like nsInt64(PR_Now()) / nsInt64(long(PR_USEC_PER_SEC)) so at the very least, can we get some operators added to nsTime(), get a PRUint64 ctor for nsInt64(), and get some nice nsInt64/nsTime compatible convenience constants? perhaps we should be making nsTime inherit from nsInt64 instead...
-> alec.
Assignee: dougt → alecf
My mozilla 1.4b is already looking cramped. patches accepted :)
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.5alpha
Attached patch patchSplinter Review
this should help... makes nsTime inherit from nsInt64
Assignee: alecf → cbiesinger
Attachment #151251 - Flags: superreview?(dougt)
Attachment #151251 - Flags: review?(bsmedberg)
Target Milestone: mozilla1.5alpha → mozilla1.8alpha2
Attachment #151251 - Flags: review?(bsmedberg) → review+
Target Milestone: mozilla1.8alpha2 → mozilla1.8beta
Comment on attachment 151251 [details] [diff] [review] patch looks fine. Anyone interested in moving this out of XPCOM and into mailnews -- the main customer of this class?
Attachment #151251 - Flags: superreview?(dougt) → superreview+
Checking in nsTime.h; /cvsroot/mozilla/xpcom/ds/nsTime.h,v <-- nsTime.h new revision: 3.11; previous revision: 3.10 done dwitte wants to use this in cookie code afaik, so moving this into mailnews would be out...
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.8beta → mozilla1.8alpha3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: