Skip to content

Commit 340243e

Browse files
mattytrentinidpgeorge
authored andcommitted
time: Add README to explain the purpose of the time extension library.
Signed-off-by: Matt Trentini <[email protected]>
1 parent 83f3991 commit 340243e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

python-stdlib/time/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
```

0 commit comments

Comments
 (0)