Use en_US_POSIX locale for
dates from the network
Use Gregorian calendar too
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
Do not forget to set
the same Locale
for both NSCalendar and
NSDateFormatter
Slide 20
Slide 20 text
Or let my library do it for you
dodikk / ESLocale
Slide 21
Slide 21 text
Ok. How about SQLite?
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
SELECT SUM( Visits)
FROM VisitsLog
WHERE Date BETWEEN
x AND y
GROUP BY week
Slide 24
Slide 24 text
What should I take as week ?
Slide 25
Slide 25 text
SELECT SUM( Visits)
FROM VisitsLog
WHERE Date BETWEEN x AND y
GROUP BY
Strftime('%Y-%W', Date )
Slide 26
Slide 26 text
SELECT SUM( Visits)
FROM VisitsLog
WHERE Date BETWEEN x AND y
GROUP BY
Strftime('%Y-%W', Date )
Slide 27
Slide 27 text
No content
Slide 28
Slide 28 text
SELECT SUM( Visits)
FROM VisitsLog
WHERE Date BETWEEN x AND y
GROUP BY
ObjcFormatDate('YYYY-ww',
Date, 'en_US_POSIX' )
Slide 29
Slide 29 text
No content
Slide 30
Slide 30 text
int sqlite3_create_function(
dbHandle,
"ObjcFormatDate",
3, //int nArg,
SQLITE_UTF8,
NULL, // sqlite user data
functionPointer,
NULL, NULL // for aggregates
);
Slide 31
Slide 31 text
Plan of attack
Convert C strings to NSString
Convert date string to NSDate
Format NSDate using locale
Slide 32
Slide 32 text
SQLite uses ANSI format
yyyy-MM-dd
Slide 33
Slide 33 text
Demo
Slide 34
Slide 34 text
One More Thing
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
1000 times slower than strftime
10K records
Creating NSDateFormatter on-the-fly
Slide 37
Slide 37 text
No content
Slide 38
Slide 38 text
Same speed as strftime
Same 10K records
Singletone NSDateFormatter