sixtyfootersdude
sixtyfootersdude

Reputation: 27231

iPhone: time from CLLocationManager

I am using a CLLocationManager to get the current location of the an iPod/iPhone. The delegate that I implement has this method:

- (void)locationManager:(CLLocationManager *)manager 
    didUpdateToLocation:(CLLocation *)newLocation 
           fromLocation:(CLLocation *)oldLocation {

I have a couple questions about the timestamp value of a CLLocation returned from this method.

For example when I print: startingLocation.timestamp this time will look like this: 2010-11-39 20:57:19 GMT.

  1. Am I guaranteed that the time stamp will be GMT?
  2. Where is the device getting this time stamp? If it is getting GPS locational data will this be the time stamp fromt he GPS? (That would be very accurate and consistent between devices). If the user has weird time settings on their device will this affect the time?

Upvotes: 2

Views: 1934

Answers (1)

grahamparks
grahamparks

Reputation: 16296

The timestamp is an NSDate object, which represents an abstract moment in time and has no particular time zone or calendar system associated with it. When you use a logging command, it's converting its internal value to GMT to make it human-readble, but that doesn't mean it's a GMT date. You can convert its internal value into any calendar or timezone you want via the NSCalendar and NSDateFormatter classes.

Apple gives no reason to assume the timestamp is derived from GPS. Its purpose is to tell you the age of the location reading, so logically it would be stamped from the system time, otherwise you wouldn't be able to reliably calculate its age (or compare its age with non-GPS readings). You could do some testing to find out for sure.

Upvotes: 2

Related Questions