Re: Two questions about NSCalendarDate
Re: Two questions about NSCalendarDate
- Subject: Re: Two questions about NSCalendarDate
- From: Magnus Strand <email@hidden>
- Date: Thu, 17 Mar 2005 10:19:04 +0100
Hi Ben!
Answer to your first question:
You can use NSDate method
timeIntervalSinceReferenceDate
|- (|NSTimeInterval
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/TypesAndConstants/FoundationTypes.html#//apple_ref/doc/c_ref/NSTimeInterval>|)|timeIntervalSinceReferenceDate||
Returns the interval between the receiver and the system’s absolute
reference date, 1 January 2001, GMT. If the receiver is earlier than the
absolute reference date, the return value is negative.
NSTimeInterval
------------------------------------------------------------------------
typedef double NSTimeInterval;
Always in seconds; yields submillisecond precision over a range of
10,000 years.
Then you can cast the NSTimeInterval to an int.
Magnus Strand
Ben Borofka wrote:
I'm using NSCalendarDate to get an NSString timestamp for my app. I
have two separate questions.
First of all, I'd like to be able to use my NSCalendarDate instance to
seed a random number generator. srandom() only takes an int as its
argument, and I'm not sure the best way to get an int value from my
NSCalendarDate. I've tried taking the NSString value of it, then
converting that to an int, but it doesn't seem to be working very
well. There is probably a much easier solution to this that I don't
know about. Anyone have any ideas?
Secondly, I want to set the timestamp format to use %m, %d and %H
without leading zeros. For example, I want:
1/4/2005 2:45 PM
instead of:
01/04/2005 02:45 PM
Is there an easy way to do this?
Thanks.
Ben
------------------------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
*Magnus Strand *
Systemutvecklare | System Developer, MSc
*Teknik i Media* | Södra Förstadsgatan 2 | 211 43 Malmö | Tel +46 40 601
57 00 | Fax +46 40 601 57 99
Direkt +46 40 601 57 16 | Mobil +46 704 20 57 16 | email@hidden
| www.tim.se
/This message contains information that may be privileged or
confidential and is the property of Teknik i Media. / /It is intended
only for the person to whom it is addressed. If you receive this message
in error, please notify the sender immediately and delete all copies of
this message. /
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden