public static TimeSpan?GetValueAsTime(this ConfigArray <string> conf, int index) { var value = conf.Value; if (value.Count == 0) { return(null); } var last = value[^ 1];
public static TimeSpan?GetValueAsTime(this ConfigArray <string> conf, int index) { var value = conf.Value; if (value.Count == 0) { return(null); } var last = value[value.Count - 1]; var repeat = last == "repeat" || last == "repeat last"; // "repeat" might get removed for other loops, but for now keep as hidden alternative var max = repeat ? value.Count - 2 : value.Count - 1; if (index <= max) { return(TomlTools.ParseTime(value[index])); } else { return(TomlTools.ParseTime(value[max])); } }