File tree 2 files changed +10
-4
lines changed
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
11
11
12
12
``` python
13
13
In [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 )
15
15
16
16
In [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 )
18
18
19
19
In [3 ]: x / 0
20
20
-------------------------------------------------------------------------- -
@@ -23,7 +23,7 @@ ZeroDivisionError Traceback (most recent call last)
23
23
---- > 1 x/ 0
24
24
25
25
ZeroDivisionError : 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 )
27
27
```
28
28
29
29
## Want to turn it off?
Original file line number Diff line number Diff line change 12
12
from IPython .core .magics .execution import _format_time as format_delta
13
13
14
14
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
+
15
21
class LineWatcher (object ):
16
22
"""Class that implements a basic timer.
17
23
@@ -30,7 +36,7 @@ def stop(self):
30
36
print (
31
37
u'time: {} (started: {})' .format (
32
38
format_delta (delta ),
33
- strftime ( '%Y-%m-%d %H:%M:%S%z' , self .timestamp ),
39
+ format_timestamp ( self .timestamp ),
34
40
)
35
41
)
36
42
You can’t perform that action at this time.
0 commit comments