Skip to content

Commit

Permalink
feat: can get now timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudingcity committed Dec 26, 2020
1 parent 0ff3994 commit 72f16c9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cmd

import (
"fmt"
"strings"
"time"

"github.com/cloudingcity/gool/pkg/date"
"github.com/spf13/cobra"
Expand All @@ -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!")
Expand Down

0 comments on commit 72f16c9

Please # to comment.