This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import logging | |
import math | |
import time | |
from functools import wraps | |
logger = logging.getLogger(__name__) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String calculateTimeAgo(long timeStamp) { | |
long timeDifference; | |
long unixTime = System.currentTimeMillis() / 1000L; //get current time in seconds. | |
int j; | |
String[] periods = {"s", "min", "hour", "day", "week", "month", "year", "decade"}; | |
// full time intervals like seconds, minutes, days and so on | |
double[] lengths = {60, 60, 24, 7, 4.35, 12, 10}; | |
timeDifference = unixTime - timeStamp; | |
String tense = "ago"; |