package clock

import "time"

// StorageTimezone is the only timezone used for persisted timestamps.
const StorageTimezone = "UTC"

// Now returns the current instant in UTC.
func Now() time.Time {
	return time.Now().UTC()
}

// NowUnixNano returns the current instant as UTC unix nanoseconds.
func NowUnixNano() int64 {
	return Now().UnixNano()
}

// UnixNano converts an instant to UTC unix nanoseconds.
func UnixNano(t time.Time) int64 {
	return t.UTC().UnixNano()
}

// FromUnixNano parses UTC unix nanoseconds.
func FromUnixNano(nano int64) time.Time {
	return time.Unix(0, nano).UTC()
}

// AddSecondsFromNow returns UTC unix nanoseconds after the given seconds.
func AddSecondsFromNow(seconds int) int64 {
	return Now().Add(time.Duration(seconds) * time.Second).UnixNano()
}

// SecondsToNanos converts whole seconds to nanoseconds.
func SecondsToNanos(seconds int) int64 {
	return int64(seconds) * int64(time.Second)
}
