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

datetime: fix negative years formatting

Negative Julian dates used to be incorrectly formatted, if there were
non-zero hour/minutes/second.

```
tarantool> T = date.new{year = -1, month = 6, day = 10, hour = 12, min = 10, sec = 10}

tarantool> T
- -001-06-11T-11:-49:-50Z
```

The problem is due to operator % in C/C++ which is returning negative
modulo toward 0. Use Euclidian (floored) modulo instead.

Correct both `tostring(T)`/`T:format()` and `strftime`-like
'T:format(fmt)'

```
tarantool> T:format()
- -001-06-10T12:10:10Z

tarantool> T:format('%FT%T.%f%z')
- -001-06-10T12:10:10.000+0000
```

Follow-up to #5941
parent 7483bcab
No related branches found
No related tags found
Loading
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