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