aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.odin5
-rw-r--r--time.odin104
2 files changed, 58 insertions, 51 deletions
diff --git a/main.odin b/main.odin
index 83e633f..1cd4b7d 100644
--- a/main.odin
+++ b/main.odin
@@ -4,6 +4,7 @@ import "core:fmt"
import "core:os"
import "core:strings"
import "core:strconv"
+import "core:sys/windows"
dayrate : f64 = 3500
@@ -31,7 +32,9 @@ Filter :: struct {
}
main :: proc() {
-
+ when ODIN_OS == .Windows {
+ windows.SetConsoleOutputCP(windows.CODEPAGE.UTF8)
+ }
arg_count := len(os.args)-1
filters : Arg_Flags = {}
parsing : Arg_Type = .NONE
diff --git a/time.odin b/time.odin
index f98f0ff..2cdbe72 100644
--- a/time.odin
+++ b/time.odin
@@ -394,57 +394,61 @@ importICS :: proc(path: string, verbose: bool = false) -> ([dynamic]Timeblock, b
// BUG: This assumes that there will never be a line shorter than 10.
// That means this will try reading out of bounds at some point.
-
- if line[0:10]=="DTSTART;TZ" {
- // grab the timestamp from the end of the line, and set start to it
-
- ll := len(line)
- if verbose do fmt.println("Found a DTSTART!")
- if verbose do fmt.println("length of line:", ll)
- if verbose do fmt.println(line)
- date_start : int
-
- if verbose do fmt.printf("Time: %s:%s\n", line[ll-6:ll-4], line[ll-4:ll-2])
-
- if verbose do fmt.printf("Hours: %s\n", line[ll-6:ll-4])
- c.start.hours = strconv.atoi(line[ll-6:ll-4])
-
- if verbose do fmt.printf("Minutes: %s\n", line[ll-4:ll-2])
- c.start.minutes = strconv.atoi(line[ll-4:ll-2])
-
- if verbose do fmt.printf("Day: %s\n", line[ll-9:ll-7])
- c.start.day = strconv.atoi(line[ll-9:ll-7])
-
- if verbose do fmt.printf("Month: %s\n", line[ll-11:ll-9])
- c.start.month = strconv.atoi(line[ll-11:ll-9])
-
- if verbose do fmt.printf("Year: %s\n", line[ll-15:ll-11])
- c.start.year = strconv.atoi(line[ll-15:ll-11])
+
+ if len(line)>=10 {
+ if line[0:10]=="DTSTART;TZ" {
+ // grab the timestamp from the end of the line, and set start to it
+
+ ll := len(line)
+ if verbose do fmt.println("Found a DTSTART!")
+ if verbose do fmt.println("length of line:", ll)
+ if verbose do fmt.println(line)
+ date_start : int
+
+ if verbose do fmt.printf("Time: %s:%s\n", line[ll-6:ll-4], line[ll-4:ll-2])
+
+ if verbose do fmt.printf("Hours: %s\n", line[ll-6:ll-4])
+ c.start.hours, _ = strconv.parse_int(line[ll-6:ll-4])
+
+ if verbose do fmt.printf("Minutes: %s\n", line[ll-4:ll-2])
+ c.start.minutes, _ = strconv.parse_int(line[ll-4:ll-2])
+
+ if verbose do fmt.printf("Day: %s\n", line[ll-9:ll-7])
+ c.start.day, _ = strconv.parse_int(line[ll-9:ll-7])
+
+ if verbose do fmt.printf("Month: %s\n", line[ll-11:ll-9])
+ c.start.month, _ = strconv.parse_int(line[ll-11:ll-9])
+
+ if verbose do fmt.printf("Year: %s\n", line[ll-15:ll-11])
+ c.start.year, _ = strconv.parse_int(line[ll-15:ll-11])
+ }
}
- if line[0:5]=="DTEND" {
- // grab the timestamp from the end of the line, and set end to it
- ll := len(line)
- if verbose do fmt.println("Found a DTEND!")
- if verbose do fmt.println(line)
-
-
- if verbose do fmt.printf("Time: %s:%s\n", line[ll-6:ll-4], line[ll-4:ll-2])
-
- if verbose do fmt.printf("Hours: %s\n", line[ll-6:ll-4])
- c.end.hours = strconv.atoi(line[ll-6:ll-4])
-
- if verbose do fmt.printf("Minutes: %s\n", line[ll-4:ll-2])
- c.end.minutes = strconv.atoi(line[ll-4:ll-2])
-
- if verbose do fmt.printf("Day: %s\n", line[ll-9:ll-7])
- c.end.day = strconv.atoi(line[ll-9:ll-7])
-
- if verbose do fmt.printf("Month: %s\n", line[ll-11:ll-9])
- c.end.month = strconv.atoi(line[ll-11:ll-9])
-
- if verbose do fmt.printf("Year: %s\n", line[ll-15:ll-11])
- c.end.year = strconv.atoi(line[ll-15:ll-11])
-
+ if len(line)>=5 {
+ if line[0:5]=="DTEND" {
+ // grab the timestamp from the end of the line, and set end to it
+ ll := len(line)
+ if verbose do fmt.println("Found a DTEND!")
+ if verbose do fmt.println(line)
+
+
+ if verbose do fmt.printf("Time: %s:%s\n", line[ll-6:ll-4], line[ll-4:ll-2])
+
+ if verbose do fmt.printf("Hours: %s\n", line[ll-6:ll-4])
+ c.end.hours, _ = strconv.parse_int(line[ll-6:ll-4])
+
+ if verbose do fmt.printf("Minutes: %s\n", line[ll-4:ll-2])
+ c.end.minutes, _ = strconv.parse_int(line[ll-4:ll-2])
+
+ if verbose do fmt.printf("Day: %s\n", line[ll-9:ll-7])
+ c.end.day, _ = strconv.parse_int(line[ll-9:ll-7])
+
+ if verbose do fmt.printf("Month: %s\n", line[ll-11:ll-9])
+ c.end.month, _ = strconv.parse_int(line[ll-11:ll-9])
+
+ if verbose do fmt.printf("Year: %s\n", line[ll-15:ll-11])
+ c.end.year, _ = strconv.parse_int(line[ll-15:ll-11])
+
+ }
}
if line[0:min(8, len(line))]=="SUMMARY:" {
if verbose do fmt.println("Found a SUMMARY!")