Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Week based calendar and iOS
Search
Oleksandr Dodatko
December 22, 2012
Programming
0
110
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
Share
More Decks by Oleksandr Dodatko
See All by Oleksandr Dodatko
From Objective-C to Xamarin
dodikk
1
230
Building libraries for iOS — Going native (v2)
dodikk
3
280
Building libraries for iOS — Going native
dodikk
2
200
iAsync Functional Programming in Objective-C
dodikk
1
190
RubyMotion : A fly in the ointment
dodikk
0
64
iContinuousIntegration
dodikk
0
87
Other Decks in Programming
See All in Programming
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
240
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.3k
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
1k
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
4k
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
430
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
420
SwiftUIで本格音ゲー実装してみた
hypebeans
0
520
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
150
Implementation Patterns
denyspoltorak
0
140
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
110
愛される翻訳の秘訣
kishikawakatsumi
3
350
脳の「省エネモード」をデバッグする ~System 1(直感)と System 2(論理)の切り替え~
panda728
PRO
0
130
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
320
WCS-LA-2024
lcolladotor
0
390
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
2.8k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
350
More Than Pixels: Becoming A User Experience Designer
marktimemedia
2
260
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
0
200
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
99
The Language of Interfaces
destraynor
162
26k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
2
3.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
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