Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In <code>AmazonSDKUtil.m</code>, we have the following methods:</p> <pre><code>+(NSDate *)convertStringToDate:(NSString *)string usingFormat:(NSString *)dateFormat { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:dateFormat]; [dateFormatter setLocale:[AmazonSDKUtil timestampLocale]]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]]; NSDate *parsed = [dateFormatter dateFromString:string]; NSDate *localDate = [parsed dateByAddingTimeInterval:_clockskew]; [dateFormatter release]; return localDate; } +(NSString *)convertDateToString:(NSDate *)date usingFormat:(NSString *)dateFormat { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]]; [dateFormatter setDateFormat:dateFormat]; [dateFormatter setLocale:[AmazonSDKUtil timestampLocale]]; NSDate *realDate = [date dateByAddingTimeInterval:-1*_clockskew]; NSString *formatted = [dateFormatter stringFromDate:realDate]; [dateFormatter release]; return formatted; } </code></pre> <p>In older versions of the SDK, the locale and timezone weren't properly set to <code>en_US</code> and <code>GMT</code>. This may cause issues depending on your device locale and timezone settings. The latest version of the SDK fixes the issue. If, for some reason, you cannot update the SDK, you can modify <code>AmazonSDKUtil.m</code> and explicitly set locale and timezone values.</p> <p><strong>EDIT:</strong></p> <p>If you run the following code snippet on iOS 6 and iOS 7, you can see how locale setting affects date format.</p> <pre><code>NSDateFormatter *dateFormatter = [NSDateFormatter new]; dateFormatter.dateFormat = @"EEE, dd MMM yyyy HH:mm:ss z"; dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"PDT"]; dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"]; NSString *dateWithoutTimezoneAndLocale = [dateFormatter stringFromDate:[NSDate date]]; NSLog(@"Date 1: %@", dateWithoutTimezoneAndLocale); dateFormatter.timeZone = [NSTimeZone timeZoneWithName:@"GMT"]; dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; NSString *dateWithTimezoneAndLocale = [dateFormatter stringFromDate:[NSDate date]]; NSLog(@"Date 2: %@", dateWithTimezoneAndLocale); </code></pre> <p><strong>On iOS 6</strong></p> <pre><code>Date 1: Wed, 25 Sep 2013 16:25:29 PDT Date 2: Wed, 25 Sep 2013 23:25:29 GMT </code></pre> <p><strong>On iOS 7</strong></p> <pre><code>Date 1: Wed, 25 Sep 2013 16:24:11 GMT-7 Date 2: Wed, 25 Sep 2013 23:24:11 GMT </code></pre> <p>As you stated before, the behavior of <code>NSDateFormatter</code> changed in iOS 7; however, the root cause of this issue is that you are not explicitly setting the locale to <code>en_US</code>. When the locale is set to something other than <code>en_US</code>, it may cause an issue. This is why we explicitly set the locale in the latest version of our SDK so that it runs on devices with any locale settings.</p> <p>Hope this makes sense,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload