Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 81563c1

Browse files
time: Add README to explain the purpose of the time extension library.
Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
1 parent e6b89ea commit 81563c1

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)

AltStyle によって変換されたページ (->オリジナル) /