]> git.lizzy.rs Git - micro.git/blob - tools/build-date.go
427ef1b1ddbb8eba8d8ede443b0986ec50ea9e6f
[micro.git] / tools / build-date.go
1 package main
2
3 import (
4         "fmt"
5         "os"
6         "strconv"
7         "time"
8 )
9
10 func main() {
11         var buildTime time.Time
12         epoch := os.Getenv("SOURCE_DATE_EPOCH")
13         if epoch != "" {
14                 i, err := strconv.Atoi(epoch)
15                 if err != nil {
16                         fmt.Errorf("SOURCE_DATE_EPOCH is not a valid integer")
17                         os.Exit(1)
18                 }
19                 buildTime = time.Unix(int64(i), 0)
20         } else {
21                 buildTime = time.Now().Local()
22         }
23         fmt.Println(buildTime.Format("January 02, 2006"))
24 }