예제 #1
0
def print_time_since_utc_timestr(s, data=None, now=None):
    """Converts from a UTC time string like 2010-12-12 15:27:41.65000
    to human readabel string like 'Last seen 4 minutes ago'

    >>> now = datetime(*(time.strptime('2010-12-12 15:27:41.650000', "%Y-%m-%d %H:%M:%S.%f")[0:6]+(0, PST)))
    >>> print_time_since_utc_timestr('2010-12-12 15:27:41.650000', now=now)
    '8 hours'
    >>> print_time_since_utc_timestr('')
    ''
    >>> print_time_since_utc_timestr(None)
    ''
    >>> print_time_since_utc_timestr('Not a valid timestamp')
    ''
    """
    ret = ''
    if s == '':
        return ''
    try:
        date_obj = datetime(*(time.strptime(s, "%Y-%m-%d %H:%M:%S.%f")[0:6] + (0, UTC)))
        ret = timesince(date_obj, now)
    except Exception, e:
        try:
            date_obj = datetime(*(time.strptime(s, "%Y-%m-%d %H:%M:%S")[0:6] + (0, UTC)))
            ret = timesince(date_obj, now)
        except Exception, e:
            try:
                date_obj = datetime(*(time.strptime(s, "%Y-%m-%dT%H:%M:%S.%fZ")[0:6] + (0, UTC)))
                ret = timesince(date_obj, now)
            except Exception, e:
                ret = "<fail>"
                pass
예제 #2
0
def print_time_since_utc_timestr(s, data=None, now=None):
    """Converts from a UTC time string like 2010-12-12 15:27:41.65000
    to human readabel string like 'Last seen 4 minutes ago'

    >>> now = datetime(*(time.strptime('2010-12-12 15:27:41.650000', "%Y-%m-%d %H:%M:%S.%f")[0:6]+(0, PST)))
    >>> print_time_since_utc_timestr('2010-12-12 15:27:41.650000', now=now)
    '8 hours'
    >>> print_time_since_utc_timestr('')
    ''
    >>> print_time_since_utc_timestr(None)
    ''
    >>> print_time_since_utc_timestr('Not a valid timestamp')
    ''
    """
    ret = ''
    if s == '':
        return ''
    try:
        date_obj = datetime(*(time.strptime(s, "%Y-%m-%d %H:%M:%S.%f")[0:6] + (0, UTC)))
        ret = timesince(date_obj, now)
    except Exception, e:
        try:
            date_obj = datetime(*(time.strptime(s, "%Y-%m-%d %H:%M:%S")[0:6] + (0, UTC)))
            ret = timesince(date_obj, now)
        except Exception, e:
            try:
                date_obj = datetime(*(time.strptime(s, "%Y-%m-%dT%H:%M:%S.%fZ")[0:6] + (0, UTC)))
                ret = timesince(date_obj, now)
            except Exception, e:
                ret = "<fail>"
                pass
예제 #3
0
def updateTimeLineListStore(statuses, liststore):
    liststore.clear()
    for status in statuses:
        im, ext = fetchImageFromUrl(status.user.profile_image_url)
        pixbuf = Image_to_GdkPixbuf(im)
        time_ago = timesince.timesince(time.strptime(status.created_at.replace("+0000 ", ""), "%a %b %d %H:%M:%S %Y"))

        row = liststore.append()
        liststore.set_value(row, 0, pixbuf)
        liststore.set_value(
            row,
            1,
            '<span size="medium"><b>%s</b> (%s)\n%s\n</span><span size="x-small">%s ago</span>'
            % (status.user.screen_name, cgi.escape(status.user.name), cgi.escape(status.text), time_ago),
        )
        liststore.set_value(row, 2, status.user.screen_name)
        liststore.set_value(row, 3, status.created_at)
        liststore.set_value(row, 4, status.source)
예제 #4
0
파일: minibook.py 프로젝트: imrehg/minibook
    def status_format(self, column, cell, store, position):
        """
        Format how status update should look in list
        """

        uid = store.get_value(position, Columns.UID)
        name = self.friendsname[uid]
        status = store.get_value(position, Columns.STATUS)
        posttime = store.get_value(position, Columns.DATETIME)

        #replace characters that would choke the markup
        status = re.sub(r'&', r'&amp;', status)
        status = re.sub(r'<', r'&lt;', status)
        status = re.sub(r'>', r'&gt;', status)
        markup = ('<b>%s</b> %s\n(%s ago)' % \
                (name, status, timesince.timesince(posttime)))
        _log.debug('Marked up text: %s' % (markup))
        cell.set_property('markup', markup)
        return
예제 #5
0
    def timesince(self):
	"""Readable form for this object's timestamp."""
        return timesince.timesince(self.timestamp)
예제 #6
0
 def timesince(self):
     """Readable form for this object's timestamp."""
     return timesince.timesince(self.timestamp)
예제 #7
0
def print_time_since_utc(i, data=None):
    if i == None or i == '':
        return ''
    return timesince(datetime.fromtimestamp((i/1000)))
예제 #8
0
def print_time_since_utc(i, data=None):
    if i == None or i == '':
        return ''
    return timesince(datetime.fromtimestamp((i/1000)))
예제 #9
0
 def timesince(self):
     """Readable form for this action's timestamp."""
     return timesince.timesince(self.timestamp)
예제 #10
0
파일: main.py 프로젝트: Kauhsa/tsoha-toot
def ts(s):
    return timesince(s)
예제 #11
0
    def timesince(self):
	"""Readable form for this action's timestamp."""
        return timesince.timesince(self.timestamp)