time(it) magic: format timespans up to hours in human readable form

* Refactor time formatting of timeit into a new function
* Add minutes and hours for long running cells/lines
* Convert time and timeit magic to use the new function

Minutes and hours are float formatted, so 1.5 h is "1 hour, 30 minutes".

Signed-off-by: Jan Schulz <jasc@gmx.net>
time magic: make it usable as cell magic

Convert time to be usable as cell level magic. Also fix some examples,
which didn't have a '%' in front of the magic.

Signed-off-by: Jan Schulz <jasc@gmx.net>
Print a real "µs" instead of "us"

The unicode version is guarded so that it won't crash in terminals which
do not support that sign.

Signed-off-by: Jan Schulz <jasc@gmx.net>
time(it) magic: More human readable time format for value >1min

Signed-off-by: Jan Schulz <jasc@gmx.net>
time magic: fix unittests

time is now reported as '0 ns' and not '0.00 s'

Signed-off-by: Jan Schulz <jasc@gmx.net>
Test if sys.stdout has an encoding attribute

Signed-off-by: Jan Schulz <jasc@gmx.net>
time(it) magic: reorganize time formatting code

Signed-off-by: Jan Schulz <jasc@gmx.net>
Merge pull request #2855 from JanSchulz/2751_timit

time(it) magic: Implement minutes/hour formatting and "%%time" cell magic