package timex import "time" const ( seconds = 1e11 milliseconds = 1e14 microseconds = 1e17 ) func TimestampToTime(ts int64) time.Time { if ts < seconds { return time.Unix(ts, 0) } if ts < milliseconds { return time.Unix(ts/1000, (ts%1000)*1e6) } if ts < microseconds { return time.Unix(ts/1e6, (ts%1e6)*1000) } return time.Unix(0, ts) }