From eb2fef4d99157eb466ff9e0d7728e16a3f53310b Mon Sep 17 00:00:00 2001 From: Yves Biener Date: Thu, 2 Nov 2023 15:20:50 +0100 Subject: [PATCH] mod: update taskwarrior time conversion --- internal/gitw/project.go | 3 ++- internal/taskwarrior/task.go | 6 ++++-- internal/taskwarrior/task_test.go | 11 ++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/gitw/project.go b/internal/gitw/project.go index 7908c84..46265d9 100644 --- a/internal/gitw/project.go +++ b/internal/gitw/project.go @@ -69,6 +69,8 @@ func (project *Project) fetch() error { return nil } +// NOTE: currently push does not support the generation of new issues or +// milestones which have been created locally only func (project *Project) Push(dry_run bool) error { if err := project.fetch(); err != nil { return err @@ -298,7 +300,6 @@ func (project *Project) merge(dry_run bool) error { tasks = nil // NOTE: reset tasks after successfully updating the issues - // TODO: merge milestones for _, milestone := range project.milestones { filter.Reset() filter.IncludeProjects(project.repository.Name) diff --git a/internal/taskwarrior/task.go b/internal/taskwarrior/task.go index 2b37007..2e79b25 100644 --- a/internal/taskwarrior/task.go +++ b/internal/taskwarrior/task.go @@ -86,13 +86,15 @@ func TaskTimeToGoTime(t string) time.Time { third = timestamp[4 : len(timestamp)-1] timestamp = strings.Join([]string{first, second, third}, ":") // TODO: identify current timezone and use correct format string (works for Europe/Berlin) - value := fmt.Sprintf("%sT%s+02:00", date, timestamp) + // FIXME: the +02:00 no longer is correct due to the time shift in CET time! it is now only +01:00 + // I'll have to use a better solution, to automatically derive the correct time + value := fmt.Sprintf("%sT%s+01:00", date, timestamp) result, err := time.Parse(time.RFC3339, value) if err != nil { fmt.Fprint(os.Stderr, err) os.Exit(-1) } - return result + return result.In(time.Local) } func GoTimeToTaskTime(t time.Time) string { diff --git a/internal/taskwarrior/task_test.go b/internal/taskwarrior/task_test.go index b3a61ff..135c521 100644 --- a/internal/taskwarrior/task_test.go +++ b/internal/taskwarrior/task_test.go @@ -6,13 +6,10 @@ import ( ) func TestTimeCoversions(t *testing.T) { - current_time := time.Now() - task_current_time := GoTimeToTaskTime(current_time) - go_current_time := TaskTimeToGoTime(task_current_time) - task_current_time = GoTimeToTaskTime(go_current_time) - current_time = TaskTimeToGoTime(task_current_time) + task_current_time := TaskTimeToGoTime(GoTimeToTaskTime(time.Now())) + go_current_time := time.Now() - if current_time.Compare(go_current_time) != -1 { - t.Fatalf("conversion failed: Expected: `%s` but got: `%s`", current_time.String(), go_current_time.String()) + if task_current_time.Format("15:04") == go_current_time.Format("15:04") { + t.Fatalf("conversion failed: Expected: `%s` but got: `%s`", task_current_time.String(), go_current_time.String()) } }