diff options
| author | Nikolaus Gotsche <n@softwarefools.com> | 2018-01-21 02:22:46 +0100 |
|---|---|---|
| committer | Nikolaus Gotsche <n@softwarefools.com> | 2018-01-21 02:22:46 +0100 |
| commit | ad7fca31d412ca605723f777ec56a7e6a45569e7 (patch) | |
| tree | e6cac6f905c36053d15ae4339c884a86ade98ed5 /sqlite.go | |
| parent | 7d8d1f9a7e46ffecc9eafc27aea10c01183255c8 (diff) | |
closeTaskTime - made working ... minding local time
Diffstat (limited to 'sqlite.go')
| -rw-r--r-- | sqlite.go | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -120,8 +120,42 @@ func newTask(proj int) { } } +func closeTaskTime(tim string) { + //timt,err := time.Parse("2006-01-02 15:04",tim) + timst,timstr := "1791-09-30 19:07","1791-09-30 19:07" + zone, _ := time.Now().Zone() + if isDate(tim) { + timstr = getDate(tim) + timst = timstr+" "+zone + } else if isTime(tim) { + timstr = time.Now().Local().Format("2006-01-02")+" "+getTime(tim) + timst = timstr+" "+zone + } else { + fmt.Println(tim,"is Not a Valid Timestring! use: 'YYYY-MM-DD HH:MM' or 'HH:MM'") + os.Exit(0) + + } + timt,err := time.Parse("2006-01-02 15:04 MST",timst) + checkErr(err) + + fmt.Println(timst,timt,opentask.start) + if (timt.After(opentask.start)) { + //timstr := timt.UTC().Format("2006-01-02 15:04") + fmt.Println("...Closing Task",opentask.id,"at",timst) + stmt, err := db.Prepare("UPDATE timetable SET stop = datetime(?,'utc') WHERE id = ?") + checkErr(err) + _, err = stmt.Exec(timstr,opentask.id) + checkErr(err) + opentask.id=0 + updateProject(opentask.projectid) + }else{ + fmt.Println("Cannot Stop before the Beginning!") + } + //fmt.Println(tim,timt) +} + func closeTask() { - if (time.Now().After(opentask.start)) { + if (time.Now().After(opentask.start.Local())) { fmt.Println("...Closing Task",opentask.id) stmt, err := db.Prepare("UPDATE timetable SET stop = datetime('now') WHERE id = ?") checkErr(err) @@ -168,7 +202,7 @@ func showOpenTask() { } else { fmt.Println("___Open Task________________") dur := float64(time.Now().Sub(opentask.start))/(1000000000*60*60) - fmt.Printf("%v: %v - (%v) - %.2f h\n",opentask.id, opentask.taskname, opentask.start.Local().Format("Mon Jan _2 2006 15:04"),dur) + fmt.Printf(" %v: %v - (%v) - %.2f h\n",opentask.id, opentask.taskname, opentask.start.Local().Format("Mon Jan _2 2006 15:04"),dur) //fmt.Println(opentask.id,":", opentask.taskname,"-", opentask.start.Local().Format("Mon Jan _2 2006 15:04"),dur,"h") } } @@ -309,7 +343,6 @@ func allProjects() { func getDate(in string) string { r := regexp.MustCompile(`(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})`) return r.FindString(in) - //fmt.Println(r.FindString(in) } func getTime(in string) string { |
