Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

handle single digit dates

  • Loading branch information...
commit 3e636be8bd538d1ac9f08b1b042cb5bc57db7206 1 parent 2d21306
@dotcode authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 hotdogs
View
7 hotdogs
@@ -32,8 +32,11 @@ soup = BeautifulSoup(page)
firstDateHeading = soup.find('div', 'heading-blue')
date = re.sub('^[^0-9]+', '', firstDateHeading.contents[0].string)
day = re.search('^[0-9]+', date)
+# add leading zero to single digit dates
+if len(day.group(0)) == 1:
+ day = '0' + day.group(0)
monthYear = re.search('[a-zA-Z]+ [0-9]+$', date)
-firstDate = day.group(0) + ' ' + monthYear.group(0)
+firstDate = day + ' ' + monthYear.group(0)
# see if that first date matches today's date
if now.strftime('%d %b %Y') == firstDate:
@@ -44,7 +47,7 @@ if now.strftime('%d %b %Y') == firstDate:
hotdogs = True
break
else:
- hotdogs = False
+ hotdogs = False
if hotdogs:
print 'Yes! there are fucking hot-dogs at King\'s Cross today.'
else:
Please sign in to comment.
Something went wrong with that request. Please try again.