2022-01-19 18:56:31 +00:00
|
|
|
/*
|
2022-01-19 21:30:30 +00:00
|
|
|
Copyright © 2022 Brian Buller <brian@bullercodeworks.com>
|
2022-01-19 18:56:31 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-01-19 21:30:30 +00:00
|
|
|
"time"
|
2022-01-19 18:56:31 +00:00
|
|
|
|
2022-01-19 21:30:30 +00:00
|
|
|
"git.bullercodeworks.com/brian/gime/util"
|
2022-01-19 18:56:31 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
// fuzzyparseCmd represents the fuzzyparse command
|
|
|
|
var fuzzyparseCmd = &cobra.Command{
|
|
|
|
Use: "fuzzyparse",
|
2022-01-19 21:30:30 +00:00
|
|
|
Short: "Fuzzy parse the given text into a RFC3339 date",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
if len(args) > 0 {
|
|
|
|
if start, err := util.ParseFuzzyTime(args[0]); err == nil {
|
|
|
|
fmt.Println(start.Format(time.RFC3339))
|
|
|
|
} else {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
2022-01-19 18:56:31 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
rootCmd.AddCommand(fuzzyparseCmd)
|
|
|
|
}
|