Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
26 lines
643 B
Go
26 lines
643 B
Go
package xtime
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Seconds creates a time.Duration based on the seconds parameter.
|
|
func Seconds(seconds int64) time.Duration {
|
|
return time.Duration(seconds) * time.Second
|
|
}
|
|
|
|
// NowAfter returns a unix date string from now plus the duration.
|
|
func NowAfter(unix time.Duration) string {
|
|
date := time.Now().Add(unix)
|
|
return FormatUnix(date)
|
|
}
|
|
|
|
// FormatUnix formats the time.Time to unix date string.
|
|
func FormatUnix(date time.Time) string {
|
|
return date.Format(time.UnixDate)
|
|
}
|
|
|
|
// FormatUnixInt formats the int timestamp to unix date string.
|
|
func FormatUnixInt(unix int64) string {
|
|
return FormatUnix(time.Unix(unix, 0))
|
|
}
|