mirror of
https://github.com/goreleaser/nfpm
synced 2026-11-30 09:56:00 +01:00
29 lines
412 B
Go
29 lines
412 B
Go
package modtime
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func FromEnv() time.Time {
|
|
epoch := os.Getenv("SOURCE_DATE_EPOCH")
|
|
if epoch == "" {
|
|
return time.Time{}
|
|
}
|
|
sde, err := strconv.ParseInt(epoch, 10, 64)
|
|
if err != nil {
|
|
return time.Time{}
|
|
}
|
|
return time.Unix(sde, 0).UTC()
|
|
}
|
|
|
|
func Get(times ...time.Time) time.Time {
|
|
for _, t := range times {
|
|
if !t.IsZero() {
|
|
return t
|
|
}
|
|
}
|
|
return time.Now()
|
|
}
|