Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```