diff options
author | San Jacobs | 2023-08-26 22:32:37 +0200 |
---|---|---|
committer | San Jacobs | 2023-08-26 22:32:37 +0200 |
commit | 2a9550709c007d530aae506a5f95bd703f6f7803 (patch) | |
tree | 9e793effcda3f8f302dd62b74c8ca7746fdda11b | |
parent | 80362dbf454bb4bc5b19deb438b7c485240ef367 (diff) | |
download | satscalc-2a9550709c007d530aae506a5f95bd703f6f7803.tar.gz satscalc-2a9550709c007d530aae506a5f95bd703f6f7803.tar.bz2 satscalc-2a9550709c007d530aae506a5f95bd703f6f7803.zip |
The start of ICS import
-rw-r--r-- | src/main.odin | 2 | ||||
-rw-r--r-- | src/time.odin | 40 |
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 --- // |