Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Week based calendar and iOS

Week based calendar and iOS

This talk covers some aspects of working with dates, calendars in iOS and SQLite

Oleksandr Dodatko

December 22, 2012
Tweet

More Decks by Oleksandr Dodatko

Other Decks in Programming

Transcript

  1. In Japan the calendar may return to year #1 at

    the day of the emperor's death
  2. -(NSDate*)parseDate:( NSString* )date_ { NSDateFormatter* df_ = [ NSDateFormatter new

    ]; df_.dateFormat = @"yyyy-MM-dd"; return [ df_ dateFromString: date_ ]; } The Typical Solution
  3. -(NSDate*)parseDate:( NSString* )date_ { NSDateFormatter* df_ = [ NSDateFormatter new

    ]; df_.dateFormat = @"yyyy-MM-dd"; return [ df_ dateFromString: date_ ]; } WRONG !
  4. Do not forget to set the same Locale for both

    NSCalendar and NSDateFormatter
  5. SELECT SUM( Visits) FROM VisitsLog WHERE Date BETWEEN x AND

    y GROUP BY ObjcFormatDate('YYYY-ww', Date, 'en_US_POSIX' )
  6. int sqlite3_create_function( dbHandle, "ObjcFormatDate", 3, //int nArg, SQLITE_UTF8, NULL, //

    sqlite user data functionPointer, NULL, NULL // for aggregates );
  7. Plan of attack Convert C strings to NSString Convert date

    string to NSDate Format NSDate using locale
  8. Contacts Oleksandr Dodatko mail/jabber : [email protected] Skype : alexander.dodatko.work Twitter

    : @dodikk88 Github : https://github.com/dodikk https://github.com/EmbeddedSources