From 72f16c9b6391822ade3b686afeb05461c4bef90d Mon Sep 17 00:00:00 2001 From: clouding Date: Sat, 26 Dec 2020 22:02:10 +0800 Subject: [PATCH] feat: can get now timestamp --- cmd/date.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/date.go b/cmd/date.go index a0e465a..14ef1da 100644 --- a/cmd/date.go +++ b/cmd/date.go @@ -2,6 +2,8 @@ package cmd import ( "fmt" + "strings" + "time" "github.com/cloudingcity/gool/pkg/date" "github.com/spf13/cobra" @@ -14,6 +16,11 @@ var dateToTimestampCmd = &cobra.Command{ Args: cobra.ExactArgs(1), DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { + if strings.ToLower(args[0]) == "now" { + fmt.Println(time.Now().Unix()) + return + } + timestamp, err := date.ToTimestamp(args[0]) if err != nil { fmt.Println("Invalid date!")