Re: Best approach to handling times
Re: Best approach to handling times
- Subject: Re: Best approach to handling times
- From: Ray Ackland <email@hidden>
- Date: Mon, 6 Oct 2003 09:39:54 +1300
Chuck,
Had a bit of a read on creating an array function. Doesn't sound too
bad, but I believe more than necessary for me (although still may still
do it as a learning experience).
The solution I went for was to store the time as a number (seconds or
milliseconds trivial as I am exchanging info with another system using
seconds so conversion has to happen at some stage). Individual times
are converted to NSTimestamp and displayed, with aggregates calculated
with @sum, and then displayed in a similar way.
I altered the original database design that I am converting (which had
a dozen fields representing all the possible events) into a table with
a link to a second table which holds two fields (in addition to the
required ones) - event type, and time. This meant that I didn't need to
duplicate code for each event type, so conversion of numbers to time
stamps was made easier.
The only problem it left me was allowing for time zones when displayed.
Being in a +12:00 zone, I had to deduct the local time zone offset from
the resulting conversion to keep it from adding 12 hours to all the
shown figures.
Thanks for the suggestions.
Ray.
On Friday, Sep 12, 2003, at 02:50 Pacific/Auckland, Chuck Hill wrote:
NSTimestamp is implemented in terms of milliseconds, so I'd use that
instead of seconds. No changes should be needed on that account.
In terms of using KVC (the @sum function etc.), take a look at the
docs for
NSArray, NSArray.Operator, and the NSArray method
public static void setOperatorForKey(String operatorName,
NSArray.Operator arrayOperator)
You should be able to derive and register your own sub-class of
NSArray.Operator that calculates total time (e.g. @totalTime).
HTH
Chuck
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.