Last active
November 19, 2022 18:46
Revisions
-
fenix-hub revised this gist
Oct 26, 2022 . 2 changed files with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ extends Resource var regex_str: String = "((?<repeat>R[0-9]+)\/)?P((?<years>[0-9]+)Y)?((?<months>[0-9]+)M)?((?<weeks>[0-9]+)W)?((?<days>[0-9]+)D)?(T((?<hours>[0-9]+)H)?((?<minutes>[0-9]+)M)?((?<seconds>[0-9]+\.?[0-9]+)?S)?)?" var regex: RegEx.new() @@ -19,9 +19,10 @@ func parse_iso_to_dict(iso_string: String) -> Dictionary: if not result: return {} return { repeat = result.get_string("repeat").rstrip("/") as int, years = result.get_string("years") as float, months = result.get_string("months") as float, weeks = result.get_string("weeks") as float, days = result.get_string("days") as float, minutes = result.get_string("minutes") as float, seconds = result.get_string("seconds") as float This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ PT2H20M10.5S P1Y3M20D P1Y3M20DT2H20M10.5S R3/PT2H20M10.5S R3/P1Y3M20D R3/P1Y3M20DT2H20M10.5S -
fenix-hub revised this gist
Oct 26, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,8 @@ func parse_iso(iso_string: String) -> RegExMatch: func parse_iso_to_dict(iso_string: String) -> Dictionary: var result: RegExMatch = parse_iso(iso_string) if not result: return {} return { repeat = result.get_string("repeat") as float, years = result.get_string("years") as float, -
fenix-hub created this gist
Oct 26, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ extends Resource var regex_str: String = "(?<repeat>R[0-9]\/)?P(?<years>[0-9]+Y)?(?<months>[0-9]+M)?([0-9]+W)?([0-9]+D)?T(?<hours>[0-9]+H)?(?<minutes>[0-9]+M)?(?<seconds>[0-9]+(\.?[0-9]+)?S)?" var regex: RegEx.new() class _init() -> void: regex.compile(regex_str) func parse_iso(iso_string: String) -> RegExMatch: var result: RegExMatch = regex.search(iso_string) if not result: printerr("Could not evaluate provided string, since it doesn't follow ISO8691!") return null return result func parse_iso_to_dict(iso_string: String) -> Dictionary: var result: RegExMatch = parse_iso(iso_string) return { repeat = result.get_string("repeat") as float, years = result.get_string("years") as float, months = result.get_string("months") as float, days = result.get_string("days") as float, minutes = result.get_string("minutes") as float, seconds = result.get_string("seconds") as float }