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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Irina Bednova
October 30, 2014
Programming
0
500
Using boolean logic to deal with dates
The unexpected application of Karnaugh maps in a Rails project
Irina Bednova
October 30, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
120
エラーログのマスキングの仕組みづくりに役立ったASTの話
kumoichi
0
180
CSC307 Lecture 15
javiergs
PRO
0
240
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
670
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
15
8.5k
手戻りゼロ? Spec Driven Developmentとは@KAG AI week
tmhirai
1
190
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
420
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
370
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
560
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1.2k
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
360
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
410
Featured
See All Featured
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
470
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
330
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
What's in a price? How to price your products and services
michaelherold
247
13k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Ruling the World: When Life Gets Gamed
codingconduct
0
170
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.4k
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