Skip to content
Snippets Groups Projects
Commit 5c7dfa9f authored by Timur Safin's avatar Timur Safin Committed by Kirill Yukhin
Browse files

datetime - %f flag support in date:format()

For the purposes of format support in datetime we need to modify
standard strftime() implementation so it will be accepting %f flag
we want to use for displaying of fractional part of seconds.

Used Olson' strftime() implementation, simplified their code and
header file, and adapted to work with our `struct datetime` data
structure.
We store timezone information there, seconds since epoch, and
nanoseconds, thus we modified a way how those have being retrieved
in the original implementation.

We have also added missing `%f` and width modifiers support.

```
tarantool> T:format('%d')
---
- '14'
...

tarantool> T:format('%3d')
---
- 3d
...
tarantool> T:format('%3f')
---
- 371
...
tarantool> T:format()
---
- 2021-09-14T12:10:30.371895+0300
...
tarantool> T:format('%FT%T.%f%z')
---
- 2021-09-14T12:10:30.371895+0300
...
```

Created detailed strftime formats test to cover all of known
format flags.

Part of #5941
parent 43e10ed3
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment