Compare commits

..

No commits in common. "fork" and "date-format-in-track-cmd" have entirely different histories.

View file

@ -3,9 +3,8 @@ package z
import ( import (
"os" "os"
"fmt" "fmt"
"time"
"strings" "strings"
"github.com/jinzhu/now"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -26,7 +25,7 @@ var entryCmd = &cobra.Command{
if begin != "" || finish != "" || project != "" || notes != "" || task != "" { if begin != "" || finish != "" || project != "" || notes != "" || task != "" {
if begin != "" { if begin != "" {
entry.Begin, err = now.Parse(begin) entry.Begin, err = time.Parse(time.RFC3339, begin)
if err != nil { if err != nil {
fmt.Printf("%s %+v\n", CharError, err) fmt.Printf("%s %+v\n", CharError, err)
os.Exit(1) os.Exit(1)
@ -34,7 +33,7 @@ var entryCmd = &cobra.Command{
} }
if finish != "" { if finish != "" {
entry.Finish, err = now.Parse(finish) entry.Finish, err = time.Parse(time.RFC3339, finish)
if err != nil { if err != nil {
fmt.Printf("%s %+v\n", CharError, err) fmt.Printf("%s %+v\n", CharError, err)
os.Exit(1) os.Exit(1)
@ -67,8 +66,8 @@ var entryCmd = &cobra.Command{
func init() { func init() {
rootCmd.AddCommand(entryCmd) rootCmd.AddCommand(entryCmd)
entryCmd.Flags().StringVarP(&begin, "begin", "b", "", "Update date/time the activity began at") entryCmd.Flags().StringVarP(&begin, "begin", "b", "", "Update date/time the activity began at\n\nUse RFC3339 format.")
entryCmd.Flags().StringVarP(&finish, "finish", "s", "", "Update date/time the activity finished at") entryCmd.Flags().StringVarP(&finish, "finish", "s", "", "Update date/time the activity finished at\n\nUse RFC3339 format.")
entryCmd.Flags().StringVarP(&project, "project", "p", "", "Update activity project") entryCmd.Flags().StringVarP(&project, "project", "p", "", "Update activity project")
entryCmd.Flags().StringVarP(&notes, "notes", "n", "", "Update activity notes") entryCmd.Flags().StringVarP(&notes, "notes", "n", "", "Update activity notes")
entryCmd.Flags().StringVarP(&task, "task", "t", "", "Update activity task") entryCmd.Flags().StringVarP(&task, "task", "t", "", "Update activity task")