diff options
-rw-r--r-- | src/c_go2work.go | 26 | ||||
-rw-r--r-- | src/u_prints.go | 46 | ||||
-rw-r--r-- | src/u_utils.go | 6 |
3 files changed, 50 insertions, 28 deletions
diff --git a/src/c_go2work.go b/src/c_go2work.go index 3daa17b..6cf5ab4 100644 --- a/src/c_go2work.go +++ b/src/c_go2work.go @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/c_go2work.go - * Tue Mar 29 22:14:51 CEST 2022 + * Tue Mar 29 22:32:07 CEST 2022 * Joe * * The main. @@ -64,7 +64,8 @@ const ( ) func main() { - var dest_t [2]int + var dest_t [3]byte + var tmp int log.SetPrefix(PROGNAME + ": ") log.SetFlags(0) if len(os.Args[0:]) == 1 { @@ -84,8 +85,11 @@ func main() { } curr_t := get_time() str_dest_t := strings.Split(os.Args[1], ":") - dest_t[HOURS], _ = strconv.Atoi(str_dest_t[HOURS]) - dest_t[MINS], _ = strconv.Atoi(str_dest_t[MINS]) + tmp, _ = strconv.Atoi(str_dest_t[HOURS]) + dest_t[HOURS] = byte(tmp) + tmp, _ = strconv.Atoi(str_dest_t[MINS]) + dest_t[MINS] = byte(tmp) + dest_t[SECS] = 0 // dest_t = [2]int{0, 0} ticker := time.NewTicker(1 * time.Second) quit := make(chan struct{}) @@ -111,12 +115,16 @@ func main() { } } -func get_time() [3]int { - var curr_t [3]int +func get_time() [3]byte { + var curr_t [3]byte + var tmp int now := time.Now() t := strings.Split(now.Format("15:04:05"), ":") - curr_t[HOURS], _ = strconv.Atoi(t[HOURS]) - curr_t[MINS], _ = strconv.Atoi(t[MINS]) - curr_t[SECS], _ = strconv.Atoi(t[SECS]) + tmp, _ = strconv.Atoi(t[HOURS]) + curr_t[HOURS] = byte(tmp) + tmp, _ = strconv.Atoi(t[MINS]) + curr_t[MINS] = byte(tmp) + tmp, _ = strconv.Atoi(t[SECS]) + curr_t[SECS] = byte(tmp) return curr_t } diff --git a/src/u_prints.go b/src/u_prints.go index 45c48eb..6233763 100644 --- a/src/u_prints.go +++ b/src/u_prints.go @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/u_prints.go - * Tue Mar 29 22:15:02 CEST 2022 + * Tue Mar 29 22:41:23 CEST 2022 * Joe * * Stuff to print @@ -49,26 +49,40 @@ package main import ( "fmt" - "strconv" ) -func print_time(t []string) { +func print_time(t [3]byte) { fmt.Print("\rTime is: ", t[HOURS], ":", t[MINS], ":", t[SECS]) } -func print_time_left(curr_t []int, dest_t []int) { - var left_t [2]int - left_t = int{0, 0} - h, _ := strconv.Atoi(curr) - m - s, _ := strconv.Atoi(curr_t[SECS]) - s = 60 - s - fmt.Print( - "\rTime left to sleep: ", - left_t[HOURS], "h ", - left_t[MINS], "m ", - s, "s", - ) +func print_time_left(curr_t [3]byte, dest_t [3]byte) { + curr_secs := time_to_seconds(curr_t) + dest_secs := time_to_seconds(dest_t) + left_secs := curr_secs - dest_secs + fmt.Println("left_secs: [", left_secs, "]") + // left_t := seconds_to_time(left_secs) + // if left_secs < 60 { + // fmt.Print( + // "\r", + // left_t[SECS], "s", + // " left to sleep", + // ) + // } else if left_secs < 3600 { + // fmt.Print( + // "\r", + // left_t[MINS], "m ", + // left_t[SECS], "s", + // " left to sleep", + // ) + // } else { + // fmt.Print( + // "\r", + // left_t[HOURS], "h ", + // left_t[MINS], "m ", + // left_t[SECS], "s", + // " left to sleep", + // ) + // } } func print_help() { diff --git a/src/u_utils.go b/src/u_utils.go index 88b8768..a0c5008 100644 --- a/src/u_utils.go +++ b/src/u_utils.go @@ -39,14 +39,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/u_utils.go - * Tue Mar 29 22:15:50 CEST 2022 + * Tue Mar 29 22:32:20 CEST 2022 * Joe */ package main -func time_to_seconds(time [3]int) int { +func time_to_seconds(time [3]byte) uint16 { } -func seconds_to_time(seconds int) [3]int { +func seconds_to_time(seconds uint16) [3]byte { } |