Ejemplo n.º 1
0
 def parseDateTime(s):
     t = DateTimeFromString(s)
     # needs to be converted to datetime
     try:
         return datetime.fromtimestamp(t)
     except Exception:  # out of range for timestamp values
         return datetime(*t.tuple()[:6])
Ejemplo n.º 2
0
    def post_process(self, value, locals, globals):

        from mx.DateTime.Parser import DateTimeFromString
        return DateTimeFromString(value)
Ejemplo n.º 3
0
 statuses = api.GetUserTimeline(name)
 start = date.today()
 if opts.today:
     end = date.today() + timedelta(days=1)
 else:
     start = date.today() + timedelta(days=1)
     end = date.today() + timedelta(days=8)
 kwargs = {
     'category_id': cid,
     'date_start': start,
     'date_end': end
 }
 tree = get_api_tree('event', 'search', **kwargs)
 for event in tree.iter('event'):
     repeat = False
     when = DateTimeFromString(event.find('when').text)
     event_name = event.find('name').text
     if opts.today:
         when_day = 'TODAY!'
     else:
         when_day = when.strftime('on %A, %B %d')
     when_time = when.strftime('at %I:%M %p')
     when_str = ' '.join((when_day, when_time))
     min_price = float(event.find('min_price').text)
     # bit.ly time
     kwargs = { 'longUrl': event.find('url').text }
     kwargs.update(BITLY)
     req = 'http://api.bit.ly/shorten?%s' % urllib.urlencode(kwargs)
     # Okay, this is kinda lazy
     result = eval(urllib.urlopen(req).read())
     rr = result['results']