File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ # time
2+
3+ This library _ extends_ the built-in [ MicroPython ` time `
4+ module] ( https://docs.micropython.org/en/latest/library/time.html#module-time ) to
5+ include
6+ [ ` time.strftime() ` ] ( https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior ) .
7+
8+ ` strftime() ` is omitted from the built-in ` time ` module to conserve space.
9+
10+ ## Installation
11+
12+ Use ` mip ` via ` mpremote ` :
13+
14+ ``` bash
15+ > mpremote mip install time
16+ ```
17+
18+ See [ Package management] ( https://docs.micropython.org/en/latest/reference/packages.html ) for more details on using ` mip ` and ` mpremote ` .
19+
20+ ## Common uses
21+
22+ ` strftime() ` is used when using a loggging [ Formatter
23+ Object] ( https://docs.python.org/3/library/logging.html#formatter-objects ) that
24+ employs
25+ [ ` asctime ` ] ( https://docs.python.org/3/library/logging.html#formatter-objects ) .
26+
27+ For example:
28+
29+ ``` python
30+ logging.Formatter(' %(asctime)s | %(name)s | %(levelname)s - %(message)s ' )
31+ ```
32+
33+ The expected output might look like:
34+
35+ ``` text
36+ Tue Feb 17 09:42:58 2009 | MAIN | INFO - test
37+ ```
38+
39+ But if this ` time ` extension library isn't installed, ` asctime ` will always be
40+ ` None ` :
41+
42+
43+ ``` text
44+ None | MAIN | INFO - test
45+ ```
You can’t perform that action at this time.
0 commit comments