Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Week based calendar and iOS
Search
Oleksandr Dodatko
December 22, 2012
Programming
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Week based calendar and iOS
This talk covers some aspects of working with dates, calendars in iOS and SQLite
Oleksandr Dodatko
December 22, 2012
More Decks by Oleksandr Dodatko
See All by Oleksandr Dodatko
From Objective-C to Xamarin
dodikk
1
250
Building libraries for iOS — Going native (v2)
dodikk
3
310
Building libraries for iOS — Going native
dodikk
2
220
iAsync Functional Programming in Objective-C
dodikk
1
200
RubyMotion : A fly in the ointment
dodikk
0
84
iContinuousIntegration
dodikk
0
110
Other Decks in Programming
See All in Programming
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
3.1k
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
320
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
0
190
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
170
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
290
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
1
150
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
240
DroidKaigi 2026 「個人開発という実験場: Android エンジニアが手にする4つの自由」
slashnephy
0
230
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
130
Security issues being discussed on Web Platforms
petamoriken
0
950
setup-vp GitLab対応の裏側
naokihaba
0
100
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.6k
Featured
See All Featured
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
Claude Code のすすめ
schroneko
67
230k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.8k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
540
Practical Orchestrator
shlominoach
192
12k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Everyday Curiosity
cassininazir
0
320
30 Presentation Tips
portentint
PRO
1
400
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Transcript
Dodatko Alexander November 2012
None
How many months does the year consist of?
What is the first day of the year?
What day does a new week start on?
Right, but did you know that ...
Jewish calendar consists of 13 months. And month #6 is
a leaping one.
In Japan the calendar may return to year #1 at
the day of the emperor's death
In Russia week starts on Monday. In the USA the
first day is Sunday
None
Dates must look in the way the user expects
None
None
-(NSDate*)parseDate:( NSString* )date_ { NSDateFormatter* df_ = [ NSDateFormatter new
]; df_.dateFormat = @"yyyy-MM-dd"; return [ df_ dateFromString: date_ ]; } The Typical Solution
-(NSDate*)parseDate:( NSString* )date_ { NSDateFormatter* df_ = [ NSDateFormatter new
]; df_.dateFormat = @"yyyy-MM-dd"; return [ df_ dateFromString: date_ ]; } WRONG !
None
Use en_US_POSIX locale for dates from the network Use Gregorian
calendar too
None
Do not forget to set the same Locale for both
NSCalendar and NSDateFormatter
Or let my library do it for you dodikk /
ESLocale
Ok. How about SQLite?
None
SELECT SUM( Visits) FROM VisitsLog WHERE Date BETWEEN x AND
y GROUP BY week
What should I take as week ?
SELECT SUM( Visits) FROM VisitsLog WHERE Date BETWEEN x AND
y GROUP BY Strftime('%Y-%W', Date )
SELECT SUM( Visits) FROM VisitsLog WHERE Date BETWEEN x AND
y GROUP BY Strftime('%Y-%W', Date )
None
SELECT SUM( Visits) FROM VisitsLog WHERE Date BETWEEN x AND
y GROUP BY ObjcFormatDate('YYYY-ww', Date, 'en_US_POSIX' )
None
int sqlite3_create_function( dbHandle, "ObjcFormatDate", 3, //int nArg, SQLITE_UTF8, NULL, //
sqlite user data functionPointer, NULL, NULL // for aggregates );
Plan of attack Convert C strings to NSString Convert date
string to NSDate Format NSDate using locale
SQLite uses ANSI format yyyy-MM-dd
Demo
One More Thing
None
1000 times slower than strftime 10K records Creating NSDateFormatter on-the-fly
None
Same speed as strftime Same 10K records Singletone NSDateFormatter
Thread Safety
dodikk / ESLocale
Contacts Oleksandr Dodatko mail/jabber :
[email protected]
Skype : alexander.dodatko.work Twitter
: @dodikk88 Github : https://github.com/dodikk https://github.com/EmbeddedSources
None