Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Command = &cli.Command{ Name: "time", Usage: "Common operations handling time.", Subcommands: []*cli.Command{ { Name: "since", Usage: "Compute how much time has elapsed since the provided time.", Action: func(ctx *cli.Context) error { if ctx.NArg() < 1 { return fmt.Errorf("missing time as first argument") } arg0 := ctx.Args().Get(0) var t time.Time var err error for _, format := range supportedFormats { t, err = time.Parse(format, arg0) if err == nil { break } } if err != nil { return fmt.Errorf("failed to parse input time using known formats") } elapsed := time.Since(t) out := "" if elapsed > day { out += strconv.FormatInt(int64(elapsed/day), 10) + "d" elapsed = elapsed % day } out += elapsed.String() _, err = ctx.App.Writer.Write([]byte(out)) return err }, }, }, Action: func(ctx *cli.Context) error { now := time.Now().Format(time.RFC3339) _, err := ctx.App.Writer.Write([]byte(now)) return err }, } )
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.