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
Showing
- src/CMakeLists.txt 2 additions, 2 deletionssrc/CMakeLists.txt
- src/lib/CMakeLists.txt 1 addition, 0 deletionssrc/lib/CMakeLists.txt
- src/lib/core/CMakeLists.txt 2 additions, 1 deletionsrc/lib/core/CMakeLists.txt
- src/lib/core/datetime.c 17 additions, 9 deletionssrc/lib/core/datetime.c
- src/lib/core/datetime.h 8 additions, 0 deletionssrc/lib/core/datetime.h
- src/lib/tzcode/CMakeLists.txt 2 additions, 0 deletionssrc/lib/tzcode/CMakeLists.txt
- src/lib/tzcode/private.h 118 additions, 0 deletionssrc/lib/tzcode/private.h
- src/lib/tzcode/strftime.c 637 additions, 0 deletionssrc/lib/tzcode/strftime.c
- src/lib/tzcode/tzcode.h 61 additions, 0 deletionssrc/lib/tzcode/tzcode.h
- src/lua/datetime.lua 17 additions, 3 deletionssrc/lua/datetime.lua
- test/app-tap/datetime.test.lua 117 additions, 5 deletionstest/app-tap/datetime.test.lua
- test/unit/CMakeLists.txt 1 addition, 1 deletiontest/unit/CMakeLists.txt
- test/unit/datetime.c 5 additions, 30 deletionstest/unit/datetime.c
- test/unit/datetime.result 142 additions, 142 deletionstest/unit/datetime.result
Loading
Please register or sign in to comment