mod: update taskwarrior time conversion

This commit is contained in:
2023-11-02 15:20:50 +01:00
parent a5f6d0511c
commit eb2fef4d99
3 changed files with 10 additions and 10 deletions

View File

@@ -69,6 +69,8 @@ func (project *Project) fetch() error {
return nil 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 { func (project *Project) Push(dry_run bool) error {
if err := project.fetch(); err != nil { if err := project.fetch(); err != nil {
return err return err
@@ -298,7 +300,6 @@ func (project *Project) merge(dry_run bool) error {
tasks = nil // NOTE: reset tasks after successfully updating the issues tasks = nil // NOTE: reset tasks after successfully updating the issues
// TODO: merge milestones
for _, milestone := range project.milestones { for _, milestone := range project.milestones {
filter.Reset() filter.Reset()
filter.IncludeProjects(project.repository.Name) filter.IncludeProjects(project.repository.Name)

View File

@@ -86,13 +86,15 @@ func TaskTimeToGoTime(t string) time.Time {
third = timestamp[4 : len(timestamp)-1] third = timestamp[4 : len(timestamp)-1]
timestamp = strings.Join([]string{first, second, third}, ":") timestamp = strings.Join([]string{first, second, third}, ":")
// TODO: identify current timezone and use correct format string (works for Europe/Berlin) // 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) result, err := time.Parse(time.RFC3339, value)
if err != nil { if err != nil {
fmt.Fprint(os.Stderr, err) fmt.Fprint(os.Stderr, err)
os.Exit(-1) os.Exit(-1)
} }
return result return result.In(time.Local)
} }
func GoTimeToTaskTime(t time.Time) string { func GoTimeToTaskTime(t time.Time) string {

View File

@@ -6,13 +6,10 @@ import (
) )
func TestTimeCoversions(t *testing.T) { func TestTimeCoversions(t *testing.T) {
current_time := time.Now() task_current_time := TaskTimeToGoTime(GoTimeToTaskTime(time.Now()))
task_current_time := GoTimeToTaskTime(current_time) go_current_time := time.Now()
go_current_time := TaskTimeToGoTime(task_current_time)
task_current_time = GoTimeToTaskTime(go_current_time)
current_time = TaskTimeToGoTime(task_current_time)
if current_time.Compare(go_current_time) != -1 { if task_current_time.Format("15:04") == go_current_time.Format("15:04") {
t.Fatalf("conversion failed: Expected: `%s` but got: `%s`", current_time.String(), go_current_time.String()) t.Fatalf("conversion failed: Expected: `%s` but got: `%s`", task_current_time.String(), go_current_time.String())
} }
} }