Hi, all. I have received so much help from this list that I wanted to share a small something back. It is a subclass of NSNumberFormatter to format time duration. It works for me but I'm sure it could be improved as well. You can download it from my iDisk public folder (http://idisk.mac.com/jrphelps-Public from the web) under Code/JPDurationToDecimalNumberFormatter.zip

I wrote this class for a calculator application for computing selling prices for products based on time required and an hourly rate. It could also be used for a billing application or anywhere else time formatting is desirable.

It handles times in the format [dd:]hh:mm meaning that if there are two components, it reads as hours and minutes but if you add a third component it reads as days, hours, and minutes. It then converts this value into a decimal number representing the number of hours. So, 12:15 would be 12.25, 1:13:45 would be 37.75. If the user enters anything other than a colon separated string, it falls back to super. It can also handle input as a decimal and then convert it to time formatted string so 8.5 can be entered and display as 8:30.

Anyway, I hope someone finds it useful and I welcome your thoughts, comments, and improvements. I have licensed it as a Creative Commons Attribution-Share Alike 3.0 United States license. If this is too restrictive, tell me. What I want is the "Don't Be a Jerk" and "Tell Me If You Use It" license. :)

Cheers,
Jamie
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to