9 |
9 |
10 import time |
10 import time |
11 import stat |
11 import stat |
12 import os |
12 import os |
13 |
13 |
|
14 MPY_EPOCH = time.mktime((2000, 1, 1, 0, 0, 0, 0, 1, -1)) |
|
15 # MPy epoch is 2000-01-01 0:0:0 UTC |
14 |
16 |
15 def mtime2string(mtime): |
17 |
|
18 def mtime2string(mtime, adjustEpoch=False): |
16 """ |
19 """ |
17 Function to convert a time value to a string representation. |
20 Function to convert a time value to a string representation. |
18 |
21 |
19 @param mtime time value |
22 @param mtime time value |
20 @type int |
23 @type int |
|
24 @param adjustEpoch flag indicating to adjust the time for the difference |
|
25 of the MPy epoch (defaults to False) |
|
26 @type bool (optional) |
21 @return string representation of the given time |
27 @return string representation of the given time |
22 @rtype str |
28 @rtype str |
23 """ |
29 """ |
|
30 if adjustEpoch: |
|
31 mtime += MPY_EPOCH |
24 return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(mtime)) |
32 return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(mtime)) |
25 |
33 |
26 |
34 |
27 def mode2string(mode): |
35 def mode2string(mode): |
28 """ |
36 """ |