"""!backtothefuture <date> returns the delorean dashboard with the specified <date>"""

import re
import parsedatetime


p = parsedatetime.Calendar()


def backtothefutureday(datestr):
    dt = p.parse(datestr)[0]
    return 'http://www.itsbacktothefutureday.com/images/{year}/{month}/{day}.jpg'.format(year=dt.tm_year, month=dt.tm_mon, day=dt.tm_mday)


def on_message(msg, server):
    text = msg.get("text", "")
    match = re.findall(r"!backtothefuture (.*)", text)
    if match:
        return backtothefutureday(match[0])

"""!backtothefuture <date> returns the delorean dashboard with the specified <date>"""

import re
import time

import parsedatetime
p = parsedatetime.Calendar()


def backtothefutureday(datestr):
    dt, result = p.parse(datestr)
    if result == 0:
        return "I'm not eating that bogus date."
    if not isinstance(dt, time.struct_time):
        if len(dt) != 9:
            return 'Could not extrapolate date values from parsed date. Your date smells bogus.'
        dt = time.struct_time(dt)
    year, month, day = dt.tm_year, dt.tm_mon, dt.tm_mday
    return 'http://www.itsbacktothefutureday.com/images/{year}/{month:02d}/{day:02d}.jpg'.format(year=year, month=month, day=day)


def on_message(msg, server):
    text = msg.get("text", "")
    match = re.findall(r"!backtothefuture (.*)", text)
    if match:
        return backtothefutureday(match[0])

Fix some bugs with date parsing, as well as zero pad month and day in URL
Fix some bugs with date parsing, as well as zero pad month and day in URL

  """!backtothefuture <date> returns the delorean dashboard with the specified <date>"""
  
  import re
+ import time
+ 
  import parsedatetime
- 
- 
  p = parsedatetime.Calendar()
  
  
  def backtothefutureday(datestr):
-     dt = p.parse(datestr)[0]
+     dt, result = p.parse(datestr)
+     if result == 0:
+         return "I'm not eating that bogus date."
+     if not isinstance(dt, time.struct_time):
+         if len(dt) != 9:
+             return 'Could not extrapolate date values from parsed date. Your date smells bogus.'
+         dt = time.struct_time(dt)
+     year, month, day = dt.tm_year, dt.tm_mon, dt.tm_mday
-     return 'http://www.itsbacktothefutureday.com/images/{year}/{month}/{day}.jpg'.format(year=dt.tm_year, month=dt.tm_mon, day=dt.tm_mday)
+     return 'http://www.itsbacktothefutureday.com/images/{year}/{month:02d}/{day:02d}.jpg'.format(year=year, month=month, day=day)
  
  
  def on_message(msg, server):
      text = msg.get("text", "")
      match = re.findall(r"!backtothefuture (.*)", text)
      if match:
          return backtothefutureday(match[0])
  
Fix some bugs with date parsing, as well as zero pad month and day in URL
## Code Before:
"""!backtothefuture <date> returns the delorean dashboard with the specified <date>"""

import re
import parsedatetime


p = parsedatetime.Calendar()


def backtothefutureday(datestr):
    dt = p.parse(datestr)[0]
    return 'http://www.itsbacktothefutureday.com/images/{year}/{month}/{day}.jpg'.format(year=dt.tm_year, month=dt.tm_mon, day=dt.tm_mday)


def on_message(msg, server):
    text = msg.get("text", "")
    match = re.findall(r"!backtothefuture (.*)", text)
    if match:
        return backtothefutureday(match[0])

## Instruction:
Fix some bugs with date parsing, as well as zero pad month and day in URL
## Code After:
"""!backtothefuture <date> returns the delorean dashboard with the specified <date>"""

import re
import time

import parsedatetime
p = parsedatetime.Calendar()


def backtothefutureday(datestr):
    dt, result = p.parse(datestr)
    if result == 0:
        return "I'm not eating that bogus date."
    if not isinstance(dt, time.struct_time):
        if len(dt) != 9:
            return 'Could not extrapolate date values from parsed date. Your date smells bogus.'
        dt = time.struct_time(dt)
    year, month, day = dt.tm_year, dt.tm_mon, dt.tm_mday
    return 'http://www.itsbacktothefutureday.com/images/{year}/{month:02d}/{day:02d}.jpg'.format(year=year, month=month, day=day)


def on_message(msg, server):
    text = msg.get("text", "")
    match = re.findall(r"!backtothefuture (.*)", text)
    if match:
        return backtothefutureday(match[0])
