entryCmd: Use now to parse dates
This commit is contained in:
parent
fc1aa49ea4
commit
502083ba85
1 changed files with 6 additions and 5 deletions
|
@ -3,8 +3,9 @@ package z
|
|||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
"time"
|
||||
"strings"
|
||||
|
||||
"github.com/jinzhu/now"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -25,7 +26,7 @@ var entryCmd = &cobra.Command{
|
|||
|
||||
if begin != "" || finish != "" || project != "" || notes != "" || task != "" {
|
||||
if begin != "" {
|
||||
entry.Begin, err = time.Parse(time.RFC3339, begin)
|
||||
entry.Begin, err = now.Parse(begin)
|
||||
if err != nil {
|
||||
fmt.Printf("%s %+v\n", CharError, err)
|
||||
os.Exit(1)
|
||||
|
@ -33,7 +34,7 @@ var entryCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
if finish != "" {
|
||||
entry.Finish, err = time.Parse(time.RFC3339, finish)
|
||||
entry.Finish, err = now.Parse(finish)
|
||||
if err != nil {
|
||||
fmt.Printf("%s %+v\n", CharError, err)
|
||||
os.Exit(1)
|
||||
|
@ -66,8 +67,8 @@ var entryCmd = &cobra.Command{
|
|||
|
||||
func init() {
|
||||
rootCmd.AddCommand(entryCmd)
|
||||
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\n\nUse RFC3339 format.")
|
||||
entryCmd.Flags().StringVarP(&begin, "begin", "b", "", "Update date/time the activity began at")
|
||||
entryCmd.Flags().StringVarP(&finish, "finish", "s", "", "Update date/time the activity finished at")
|
||||
entryCmd.Flags().StringVarP(&project, "project", "p", "", "Update activity project")
|
||||
entryCmd.Flags().StringVarP(¬es, "notes", "n", "", "Update activity notes")
|
||||
entryCmd.Flags().StringVarP(&task, "task", "t", "", "Update activity task")
|
||||
|
|
Loading…
Reference in a new issue