Skip to content

Commit

Permalink
brew
Browse files Browse the repository at this point in the history
  • Loading branch information
bgetsug committed Mar 8, 2018
1 parent 3ccc29e commit c7d28b3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
brew:
github:
owner: bgetsug
name: homebrew-tap
commit_author:
name: goreleaserbot
email:

builds:
-
env:
Expand Down
4 changes: 1 addition & 3 deletions cmd/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ var convCmd = &cobra.Command{

in := parseTimeFromArgs(args)

fmt.Println(in.Format(format))
fmt.Print("\n occurs at\n\n")
fmt.Println(in.In(loc).Format(format))
fmt.Println(in.Format(format), "occurs at", in.In(loc).Format(format))
},
}

Expand Down
31 changes: 21 additions & 10 deletions cmd/midnight.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,37 @@ import (
"github.com/spf13/cobra"
)

var (
days int
)

// midnightCmd represents the midnight command
var midnightCmd = &cobra.Command{
Use: "midnight",
Short: "List upcoming midnights",
Run: func(cmd *cobra.Command, args []string) {

fmt.Println("\nNext midnight will occur at:")

t := time.Now().UTC()

var midnights []string

for _, loc := range utcOffsetLocations {
midnight := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, loc)
for i := 0; i < days; i++ {
t := time.Now().UTC()

if midnight.After(t) {
midnights = append(midnights, fmt.Sprint(midnight.In(time.Local), " | ", loc.String()))
for _, loc := range utcOffsetLocations {
midnight := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, loc).AddDate(0, 0, i)

if midnight.After(t) {
midnights = append(midnights, fmt.Sprint(
midnight.In(time.Local), " | ", midnight.Format("2006-01-02 15:04:05 -0700 (MST)"),
))
}
}
}

sort.Strings(midnights)

fmt.Println("\n Local Time | UTC Offset")
fmt.Println("-------------------------------------------")
fmt.Print("\nNext midnight will occur at:\n\n")
fmt.Println(" Local Time | Zone Time ")
fmt.Println("-----------------------------------------------------------------------")

for _, midnight := range midnights {
fmt.Println(midnight)
Expand All @@ -62,4 +69,8 @@ var midnightCmd = &cobra.Command{

func init() {
RootCmd.AddCommand(midnightCmd)

flags := midnightCmd.PersistentFlags()

flags.IntVarP(&days, "days", "d", 1, "Number of days to generate")
}

0 comments on commit c7d28b3

Please sign in to comment.