Skip to content
Snippets Groups Projects
user avatar
Timur Safin authored
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
5c7dfa9f
History
Name Last commit Last update