how parse string eg. "01/21 – 02/20" represented month/day month/day. how go parsing object representation such can query many date range objects find date range.
example query , 01 / 30 , return date range object "01/21 - 02/20" falls within particular range.
if have input string "01/21 – 02/20", parse regular expression , parse matching of regex datetime
.
note, .net not contain kind of datetime range object
- should code yourself.
your result object should looks this
public class datetimerangeobject { public datetime date1 {get; set;} public datetime date2 {get; set;} public static datetimerangeobject parse(string inputstr) { var matches = regex.matches(inputstr, "\\d{2}\\/\\d{2}"); return new datetimerangeobject { date1 = datetime.parseexact(matches[0].value, "mm/dd", null), date2 = datetime.parseexact(matches[1].value, "mm/dd", null) }; } }
adding method check datetime value placed between 2 other values not hard.
Comments
Post a Comment