• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: seconds into hours ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: seconds into hours ?


  • Subject: Re: seconds into hours ?
  • From: Steve Bird <email@hidden>
  • Date: Fri, 22 Feb 2002 16:38:49 -0500

On Friday, February 22, 2002, at 04:13 , Chris Boot wrote:

Hi,

I'm looking for the best way to translate seconds into hours such as :

Sec -> Hours
10 00:00:10
60 00:01:00
71 00:01:11
and so on...

Sec is an int value.

I tried with initWithFormat without success...

(I'm writing this into my e-mail client without testing, BTW).

static NSString *secsToTime(int inSecs)
{
int s, m, h;

s = inSecs % 60;
m = (inSecs / 60) % 60;
h = inSecs / 3600;

return [NSString stringWithFormat:@"%d:%d:%d", h, m, s];
}

This should do it. Note that I haven't tried this, nor even compiled this.
I only wrote it into Entourage from my head.

That won't put the leading zeroes in it - look up the format specifiers.

-----------------------------------------------------------------
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
www.Culverson.com (toll free) 1-877-676-8175
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: seconds into hours ?
      • From: Don Murta <email@hidden>
References: 
 >Re: seconds into hours ? (From: Chris Boot <email@hidden>)

  • Prev by Date: get selective settings from NSPrintInfo
  • Next by Date: Re: number formatting
  • Previous by thread: Re: seconds into hours ?
  • Next by thread: Re: seconds into hours ?
  • Index(es):
    • Date
    • Thread