diff options
Diffstat (limited to 'src/u_utils.go')
-rw-r--r-- | src/u_utils.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/u_utils.go b/src/u_utils.go index 598efed..b1d846f 100644 --- a/src/u_utils.go +++ b/src/u_utils.go @@ -39,12 +39,18 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/u_utils.go - * Wed Mar 30 00:02:25 CEST 2022 + * Wed Mar 30 01:25:20 CEST 2022 * Joe */ package main +import ( + "time" + "strconv" + "strings" +) + func time_to_seconds(time [3]byte) uint { return (3600 * uint(time[HOURS])) + (60 * uint(time[MINS])) + @@ -61,3 +67,21 @@ func seconds_to_time(seconds uint) [3]byte { time[SECS] = byte((seconds - (hours * 3600)) - mins * 60) return time } + +func get_time() [3]byte { + var curr_t [3]byte + var tmp int + now := time.Now() + t := strings.Split(now.Format("15:04:05"), ":") + 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 +} + +func get_test_time() [3]byte { + return seconds_to_time(time_to_seconds(get_time()) + 3) +} |