title: Extract time from datetime and determine if time (not date) falls within range?
body: <p>The problem is that I want it to ignore the date and only factor in the time. Here is what I have:</p>
  
  <pre><code>import time
  from time import mktime
  from datetime import datetime
  
  def getTimeCat(Datetime):
      # extract time categories
      str_time = datetime.strptime(Datetime, "%m/%j/%y %H:%M")
      ts = datetime.fromtimestamp(mktime(str_time))
  
      # --&gt; Morning = 0400-1000
      mornStart = datetime.time(4, 0, 1)
      mornEnd = datetime.time(10, 0, 0)
  
      # --&gt; Midday = 1000-1600
      midStart = datetime.time(10, 0, 1)
      midEnd = datetime.time(16, 0, 0)
  
      # --&gt; Evening = 1600-2200
      eveStart = datetime.time(16, 0, 1)
      eveEnd = datetime.time(22, 0, 0)
  
      # --&gt; Late Night = 2200-0400
      lateStart = datetime.time(22, 0, 1)
      lateEnd = datetime.time(4, 0, 0)
  
      if time_in_range(mornStart, mornEnd, ts):
        timecat = 0 #morning
      elif time_in_range(midStart, midEnd, ts):
        timecat = 1 #midday
      elif time_in_range(eveStart, eveEnd, ts):
        timecat = 2 #evening
      elif time_in_range(lateStart, lateEnd, ts):
        timecat = 3 #late night
  
      return timecat
  </code></pre>
  
  <p>As is, I get this error:</p>
  
  <pre><code>TypeError: argument must be 9-item sequence, not datetime.datetime
  </code></pre>
  
  <p>When I change the relevant line to:</p>
  
  <pre><code>str_time = time.strptime(Datetime, "%m/%j/%y %H:%M")
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>TypeError: descriptor 'time' requires a 'datetime.datetime' object but received a 'int'
  </code></pre>
  
  <p>I know I'm working with two different libraries or whatnot, but I'm not sure how to convert between them or accomplish what I want to do only using one. I just want it to ignore the date and only check if the time is within the specified ranges. Python 2.6 is a MUST due to a library I'm using elsewhere in the code.</p>