Skip to content

Commit

Permalink
time: Add README to explain the purpose of the time extension library.
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Trentini <[email protected]>
  • Loading branch information
mattytrentini committed Oct 18, 2023
1 parent e025c84 commit 367375b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions python-stdlib/time/README.md
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
```

0 comments on commit 367375b

Please sign in to comment.