diff options
Diffstat (limited to 'time.odin')
| -rw-r--r-- | time.odin | 104 |
1 files changed, 54 insertions, 50 deletions
@@ -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!") |