Exemplo n.º 1
0
 def get_time_relative(self):
   today = date.today()# + timedelta(days = 4)
   self.time_relative = 'in ' + humanize_timeuntil(self.date)
   if self.date == today + timedelta(days = 1):
     self.time_relative = 'tomorrow'
   if self.date == today:
     self.time_relative = 'today'
   if self.date < today:
     self.time_relative = humanize_timesince(self.date)
   return self.time_relative
Exemplo n.º 2
0
    def formatmonthname(self, year, month, withyear=True):
        first = date(year, month, 1)
        next_first = first + relativedelta(months=+1)
        prev_first = first - relativedelta(months=+1)
        if withyear:
            s = '%s %s' % (calendar.month_name[month], year)
        else:
            s = '%s' % calendar.month_name[month]
        p = '%s %s' % (calendar.month_name[prev_first.month], prev_first.year)
        n = '%s %s' % (calendar.month_name[next_first.month], next_first.year)
        pf = '%s %s' % (prev_first.month, prev_first.year)
        nf = '%s %s' % (next_first.month, next_first.year)
        sf = '%s %s' % (month, year)
#        updated = get_last_update_time()
        updated = humanize_timesince(get_last_update_time())
        return '<tr id="month_nav"><th id="%s" class="this_month" colspan="7"><span id="%s" class="new_month" title="%s" onclick=""><</span><span id="%s" class="new_month" title="%s" onclick="">></span>\
                &nbsp; %s</th></tr><tr><th colspan="7">updated %s</th></tr>' % (sf, pf, p, nf, n, s, updated)