From b6dab385dbf9a626970f3673d345d0e8e6a62e1e Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Thu, 5 Oct 2023 21:53:07 +0200 Subject: Rudimentary display of actual results --- src/comfy.odin | 17 +++++++++++++++++ src/main.odin | 15 +++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/comfy.odin diff --git a/src/comfy.odin b/src/comfy.odin new file mode 100644 index 0000000..e7ef23c --- /dev/null +++ b/src/comfy.odin @@ -0,0 +1,17 @@ +package main + +import "core:strings" +import "core:strconv" + +f64_to_cstring :: proc(f: f64) -> cstring { + buf: [20]byte + result := strconv.ftoa(buf[:], f, 'f', 2, 64) + + if f > 0 { + result = string(buf[1:]) + } + + output : cstring = strings.clone_to_cstring(string(result)) + + return output +} \ No newline at end of file diff --git a/src/main.odin b/src/main.odin index 7884f28..8199e65 100644 --- a/src/main.odin +++ b/src/main.odin @@ -13,8 +13,10 @@ main :: proc() { // for cache reasons, and to simplify the process of // adding new Workdays to the array. + dayrate : f64 = 3500 workdays : [dynamic]Workday //resize(&workdays, 3) + the_big_sum : f64 = 0 { // No need to keep this array in memory forever c, _ := importICS("res/test.ics") @@ -25,9 +27,13 @@ main :: proc() { thing.start, thing.end, thing.end)) + for each_block in workdays[i].blocks { + the_big_sum += f64(each_block.value) * (dayrate/7.5) * f64(hourcount(each_block)) + } } } + //if true do return /*workday0: = new_workday({10, 22, 3, 5, 2023}, @@ -64,8 +70,13 @@ main :: proc() { defer delete(date_text) wrap_text[len(wrap_text)-1] = 0 - total_sum: cstring = "3500 NOK + 26%" - inc_soc: cstring = "4276 NOK" + + total_sum: cstring = f64_to_cstring(the_big_sum) + defer delete(total_sum) + + inc_soc: cstring = f64_to_cstring(the_big_sum*1.26) + defer delete(inc_soc) + text_height: f32 -- cgit v1.2.1