commands

package
v0.0.0-...-9b15ad8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Time = &cli.Command{
	Name:    "time",
	Aliases: []string{"t"},
	Usage:   "covert timestamp to time",
	UsageText: `timestamp t [timestamps...]

timestamp t 587433600
timestamp t 587433600 1597276800
`,
	ArgsUsage: "time [timestamp...]",
	Action: func(c *cli.Context) error {
		if c.NArg() == 0 {
			printTime(time.Now())
			return nil
		}

		for _, arg := range c.Args().Slice() {
			t, err := parseTimestamp(arg)
			if err != nil {
				return err
			}

			printTime(t)
		}

		return nil
	},
}
View Source
var Timestamp = &cli.Command{
	Name:    "timestamp",
	Aliases: []string{"ts"},
	Usage:   "covert time to timestamp",
	UsageText: `timestamp ts [date|datetime|expressions...]

timestamp ts 
timestamp ts 1988-08-13
timestamp ts "1988-08-13 18:06:06"
timestamp ts +1y -2m 3d 4h 5i 6s
`,
	ArgsUsage: `timestamp [date|datetime|expression...]`,
	Action: func(c *cli.Context) error {
		nArg := c.NArg()
		args := c.Args().Slice()
		if nArg == 0 {
			printTimestamp(time.Now())
			return nil
		} else if nArg == 1 && (len(args[0]) == dateLen || len(args[0]) == timeLen) {
			t, err := parseTime(args[0])
			if err != nil {
				return err
			}
			printTimestamp(t)
			return nil
		} else {
			t, err := str2time(args...)
			if err != nil {
				return err
			}
			printTimestamp(t)
			return nil
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL