Timing digital input high and low

I do not really know where to start, or to look for examples.
I want to have a switch and two buttons that when the switch is on one button will go to a digital input. With the switch on, I need to record the input button and how long it was high and how long it was low for many button presses.
The second button will clear the memory to start the process over.
I want to be able to put the Arduino in a learn mode push a button at different intervals of time and be able to change the switch to run mode and output what the Arduino has learned.
I hope this makes sense