This solution is written in JavaScript.
The idea is to first sort all lines alphabetically, wich will work, because the date format uses the year-month-day format. Since the lines with the start and end of sleep do not state the guard, the lines can not be parsed in isolation this time. Instead, it is necessary to use reduce on the lines array.
We need a parseLine method, that is passed the result of the previous parseLine call and the new line. We than only need to parse the minute part of the date and if this is the start of a new guard duty, or if it is the beginning of sleep or the end.
link:part1.js[role=include]
link:part1.js[role=include]
link:part1.js[role=include]
With that data, we can find the guard, that is most asleep
link:part1.js[role=include]
And get the overlapping sleep times of that guard
link:part1.js[role=include]
And put it all together
link:solution.js[role=include]