entryCmd: Use now to parse dates

This commit is contained in:
Cat /dev/Nulo 2022-09-04 21:41:43 -03:00
parent fc1aa49ea4
commit 502083ba85

View file

@ -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(&notes, "notes", "n", "", "Update activity notes")
entryCmd.Flags().StringVarP(&task, "task", "t", "", "Update activity task")