Beispiel #1
0
def tiny_timesince(d):
	t = django_timesince(d).split(',')[0]
	num, unit = t.replace(u'\xa0', u' ').split(' ')
	if num == '0':
		return u'now'
	else:
		return num + unit[0]
Beispiel #2
0
def timesince(d, now=None, reversed=False):
    """ Hack to provide second precision under 2 minutes """
    if not now:
        now = datetime.now(utc if is_aware(d) else None)
    
    delta = (d - now) if reversed else (now - d)
    s = django_timesince(d, now=now, reversed=reversed)
    
    if len(s.split(' ')) is 2:
        count, name = s.split(' ')
        if name in ['minutes', 'minute']:
            seconds = delta.seconds % 60
            extension = '%(number)d %(type)s' % {'number': seconds, 'type': 'seconds'}
            if int(count) is 0:
                return extension
            elif int(count) < 2:
                s += ', %s' % extension
    return s
Beispiel #3
0
def timesince(d, now=None, reversed=False):
    """ Hack to provide second precision under 2 minutes """
    if not now:
        now = datetime.now(utc if is_aware(d) else None)

    delta = (d - now) if reversed else (now - d)
    s = django_timesince(d, now=now, reversed=reversed)

    if len(s.split(' ')) is 2:
        count, name = s.split(' ')
        if name in ['minutes', 'minute']:
            seconds = delta.seconds % 60
            extension = '%(number)d %(type)s' % {
                'number': seconds,
                'type': 'seconds'
            }
            if int(count) is 0:
                return extension
            elif int(count) < 2:
                s += ', %s' % extension
    return s
def timesince(date):
    return django_timesince(date)
Beispiel #5
0
def timesince(date):
    return django_timesince(date)
Beispiel #6
0
 def timesince(self, now_param=None):
     return django_timesince(self.created,
                             now_param).encode('utf8').replace(
                                 b'\xc2\xa0', b' ').decode('utf8')
def timesince(date, *args, **kwargs):
    return django_timesince(date, *args, **kwargs)