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
Using boolean logic to deal with dates
Search
Irina Bednova
October 30, 2014
Programming
520
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Using boolean logic to deal with dates
The unexpected application of Karnaugh maps in a Rails project
Irina Bednova
October 30, 2014
Other Decks in Programming
See All in Programming
AIの中の人になってみる
htkym
0
110
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
300
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
200
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
130
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
290
進化を続けるGo toolsの現在地 / The Current State of Ever-Evolving Go Tools
hond0413
0
250
Dockerfile CMD for Node.js
grazie1999
0
120
Go 1.27 における memory allocation の高速化
andpad
0
300
仕様駆動開発の消費期限
watany
20
8.9k
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
1
1.9k
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
2
160
Featured
See All Featured
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Site-Speed That Sticks
csswizardry
13
1.5k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.4k
The SEO Collaboration Effect
kristinabergwall1
1
530
Git: the NoSQL Database
bkeepers
PRO
432
67k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
エンジニアに許された特別な時間の終わり
watany
108
250k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
310
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
500
Transcript
For fun Using Boolean logic to deal with dates
The problem
The problem Parse a string to a Date object
The problem • Date could be in the mm/dd/yyyy format
The problem • Date could be in the mm/dd/yyyy format
• Date could be in any format recognisable by Date.parse
The problem • Date could be in the mm/dd/yyyy format
• Date could be in any format recognisable by Date.parse • Except the dd/mm/yyyy format
month_day_year = Date.strptime(string, "%m/%d/%Y") rescue nil
month_day_year = Date.strptime(string, "%m/%d/%Y") rescue nil generic_parse = Date.parse(string) rescue
nil
month_day_year = Date.strptime(string, "%m/%d/%Y") rescue nil generic_parse = Date.parse(string) rescue
nil day_month_year = Date.strptime(string, "%d/%m/%Y") rescue nil
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 X 0 1 0 0 1 1 1 0 0 1 0 1 X 1 1 0 1 1 1
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 X 0 1 0 1 0 1 1 1 0 0 1 0 1 X 1 1 0 1 1 1
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 X 0 1 0 1 0 1 1 0 1 0 0 1 0 1 X 1 1 0 1 1 1
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 X 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 X 1 1 0 1 1 1
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 X 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 X 1 1 0 X 1 1 1
month_day_year generic_parse day_month_year result 0 0 0 0 0 0
1 X 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 X 1 1 0 X 1 1 1 1
Makes your boolean functions simpler! Karnaugh map
0 X 0 1 1 X 1 X generic_parse *
day_month_year month_day_year 1 0 00 01 11 10
0 X 0 1 1 X 1 X generic_parse *
day_month_year month_day_year 1 0 00 01 11 10
0 X 0 1 1 X 1 X generic_parse *
day_month_year month_day_year 1 0 00 01 11 10
0 X 0 1 1 X 1 X generic_parse *
day_month_year month_day_year 1 0 00 01 11 10
month_day_year 0 X 0 1 1 X 1 X generic_parse
* day_month_year month_day_year 0 00 01 11 10 1
month_day_year ∨ ¬generic_parse ∧ day_month_year 0 X 0 1 1
X 1 X generic_parse * day_month_year month_day_year 0 00 01 11 10 1
month_day_year ∨ ¬generic_parse ∧ day_month_year ∨ generic_parse ∧ ¬day_month_year 0
X 0 1 1 X 1 X generic_parse * day_month_year month_day_year 0 00 01 11 10 1
((month_day_year ? 1 : 0) + ((day_month_year ? 1 :
0) ^ (generic_parse ? 1 : 0)) == 0) month_day_year || generic_parse
Thank you! Irina Bednova @jafrog www.jafrog.com