-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
time: Add README to explain the purpose of the time extension library.
Signed-off-by: Matt Trentini <[email protected]>
- Loading branch information
1 parent
e025c84
commit 367375b
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# time | ||
|
||
This library _extends_ the built-in [MicroPython `time` | ||
module](https://docs.micropython.org/en/latest/library/time.html#module-time) to | ||
include | ||
[`time.strftime()`](https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior). | ||
|
||
`strftime()` is omitted from the built-in `time` module to conserve space. | ||
|
||
## Installation | ||
|
||
Use `mip` via `mpremote`: | ||
|
||
```bash | ||
> mpremote mip install time | ||
``` | ||
|
||
See [Package management](https://docs.micropython.org/en/latest/reference/packages.html) for more details on using `mip` and `mpremote`. | ||
|
||
## Common uses | ||
|
||
`strftime()` is used when using a loggging [Formatter | ||
Object](https://docs.python.org/3/library/logging.html#formatter-objects) that | ||
employs | ||
[`asctime`](https://docs.python.org/3/library/logging.html#formatter-objects). | ||
|
||
For example: | ||
|
||
```python | ||
logging.Formatter('%(asctime)s | %(name)s | %(levelname)s - %(message)s') | ||
``` | ||
|
||
The expected output might look like: | ||
|
||
```text | ||
Tue Feb 17 09:42:58 2009 | MAIN | INFO - test | ||
``` | ||
|
||
But if this `time` extension library isn't installed, `asctime` will always be | ||
`None`: | ||
|
||
|
||
```text | ||
None | MAIN | INFO - test | ||
``` |