timestamp

package
v0.0.0-...-35fa527 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

time 587433600
time 587433600 1597276800
`,
	ArgsUsage: "devutils 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",
	Usage: "covert text to timestamp",
	UsageText: `timestamp [date|datetime|expressions...]

timestamp 
timestamp 1988-08-13
timestamp "1988-08-13 18:06:06"
timestamp +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