From d189c077ff2a5f474cf961aaf472fbb1ab5019b9 Mon Sep 17 00:00:00 2001 From: Thane Gill Date: Fri, 18 Dec 2015 14:19:10 -0800 Subject: [PATCH] Use correct date format for GPX 1.1 --- XLocation/Categories/NSString+Gpx.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/XLocation/Categories/NSString+Gpx.m b/XLocation/Categories/NSString+Gpx.m index 9884d08..3fc3a24 100644 --- a/XLocation/Categories/NSString+Gpx.m +++ b/XLocation/Categories/NSString+Gpx.m @@ -11,7 +11,18 @@ @implementation NSString (Gpx) +(NSString *)generateGpxWithFilename:(NSString*) filename latitude:(NSNumber *)lat longitude:(NSNumber *)lng address:(NSString *)address city:(NSString *)city country:(NSString *)country zip:(NSString *)zipCode{ - return [NSString stringWithFormat:@"\n\ + + NSDateFormatter *rfc3339DateFormatter = [[NSDateFormatter alloc] init]; + NSLocale *enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; + + [rfc3339DateFormatter setLocale:enUSPOSIXLocale]; + [rfc3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"]; + [rfc3339DateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; + + NSString *dateString = [rfc3339DateFormatter stringFromDate:[NSDate new]]; + + return [NSString stringWithFormat: +@"\n\ \n\ \n\ \n\ -", lat, lng, [NSDate new], filename, address, city, country, zipCode]; +", + lat, lng, dateString, filename, address, city, country, zipCode]; } @end