import time


def _get_time_diff_to_now(ts):
    """Calculate time difference from `ts` to now in human readable format"""
    secs = abs(int(time.time() - ts))
    mins, secs = divmod(secs, 60)
    hours, mins = divmod(mins, 60)
    time_ago = ""
    if hours:
        time_ago += "%dh" % hours
    if mins:
        time_ago += "%dm" % mins
    if secs:
        time_ago += "%ds" % secs
    if time_ago:
        time_ago += " ago"
    else:
        time_ago = "just now"
    return time_ago