This commit is contained in:
Manfred Touron
2017-12-19 14:00:29 +01:00
parent 230480afd1
commit 9f831eb4de
11 changed files with 678 additions and 62 deletions

View File

@@ -51,3 +51,26 @@ func dateModify(fmt string, date time.Time) time.Time {
}
return date.Add(d)
}
func dateAgo(date interface{}) string {
var t time.Time
switch date := date.(type) {
default:
t = time.Now()
case time.Time:
t = date
case int64:
t = time.Unix(date, 0)
case int:
t = time.Unix(int64(date), 0)
}
// Drop resolution to seconds
duration := time.Since(t) / time.Second * time.Second
return duration.String()
}
func toDate(fmt, str string) time.Time {
t, _ := time.ParseInLocation(fmt, str, time.Local)
return t
}