File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,10 @@ $ pip install ipython-autotime
1111
1212``` python
1313In [1 ]: % load_ext autotime
14- time: 264 µs (started: 2020 - 12 - 15 11 :44 :36 + 0 100 )
14+ time: 264 µs (started: 2020 - 12 - 15 11 :44 :36 + 0 1 : 00 )
1515
1616In [2 ]: x = 1
17- time: 416 µs (started: 2020 - 12 - 15 11 :44 :45 + 0 100 )
17+ time: 416 µs (started: 2020 - 12 - 15 11 :44 :45 + 0 1 : 00 )
1818
1919In [3 ]: x / 0
2020-------------------------------------------------------------------------- -
@@ -23,7 +23,7 @@ ZeroDivisionError Traceback (most recent call last)
2323---- > 1 x/ 0
2424
2525ZeroDivisionError : division by zero
26- time: 88.7 ms (started: 2020 - 12 - 15 11 :44 :53 + 0 100 )
26+ time: 88.7 ms (started: 2020 - 12 - 15 11 :44 :53 + 0 1 : 00 )
2727```
2828
2929## Want to turn it off?
Original file line number Diff line number Diff line change 1212from IPython .core .magics .execution import _format_time as format_delta
1313
1414
15+ def format_timestamp (struct_time ):
16+ timestamp = strftime ('%Y-%m-%d %H:%M:%S %z' , struct_time )
17+ # add colon in %z (for datetime.fromisoformat, stackoverflow.com/q/44836581)
18+ return '{}:{}' .format (timestamp [:- 2 ], timestamp [- 2 :])
19+
20+
1521class LineWatcher (object ):
1622 """Class that implements a basic timer.
1723
@@ -30,7 +36,7 @@ def stop(self):
3036 print (
3137 u'time: {} (started: {})' .format (
3238 format_delta (delta ),
33- strftime ( '%Y-%m-%d %H:%M:%S%z' , self .timestamp ),
39+ format_timestamp ( self .timestamp ),
3440 )
3541 )
3642
You can’t perform that action at this time.
0 commit comments