aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.odin2
-rw-r--r--src/time.odin40
2 files changed, 42 insertions, 0 deletions
diff --git a/src/main.odin b/src/main.odin
index bcbaeec..729715b 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -13,6 +13,8 @@ main :: proc() {
// for cache reasons, and to simplify the process of
// adding new Workdays to the array.
+ _, _ = importICS("res/test.ics")
+
workdays: [dynamic]^Workday
resize(&workdays, 3)
diff --git a/src/time.odin b/src/time.odin
index 44c810a..f355e98 100644
--- a/src/time.odin
+++ b/src/time.odin
@@ -2,6 +2,7 @@ package main
import math "core:math"
import "core:fmt"
+import "core:os"
import "core:strings"
import "core:strconv"
import "core:slice"
@@ -366,6 +367,45 @@ upvalue :: proc(input_block: ^Timeblock, value: f32, reason: string) {
}
}
+importICS :: proc(path: string) -> ([dynamic]Timeblock, bool) {
+ output: [dynamic]Timeblock
+
+ raw, ok := os.read_entire_file_from_filename(path)
+ content := string(raw)
+
+ if !ok {
+ // TODO: Actually check the content to see if it is an ICS file.
+ fmt.eprintf("ERROR: No file found at: \"%v\"", path)
+ return output, false
+ }
+
+ for line in strings.split_lines_iterator(&content) {
+ if line[0:7]=="DTSTART" {
+ fmt.println(len(line))
+ date_start : int
+
+ for i := len(line)-1 ; i>0 ; i-=1 {
+ fmt.println(rune(line[i]))
+ }
+
+ // grab the timestamp from the end of the line, and set start to it
+ fmt.println("Found a DTSTART!")
+ fmt.println(line)
+ }
+ if line[0:5]=="DTEND" {
+ // grab the timestamp from the end of the line, and set end to it
+ fmt.println("Found a DTEND!")
+ fmt.println(line)
+ }
+ if line=="END:VEVENT" {
+ fmt.println(line)
+ //append(output, _)
+ }
+ }
+ return output, true
+}
+
+
//
// --- BASIC OPERATIONS ---
//