tarantool / tarantool/tarantool

Wrong datetime calculation (A - B + B != A)

Open
#7,145 1 comment 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

bug datetime
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Bug description

  • OS: Linux
  • OS Version: Ubuntu 20.04
  • Architecture: amd64

Unreleased version, commit 9ff8b0068411e9c1c5a414d1c70a3e963b2505e3, branch tsafin/gh-6751-olson-2

Tarantool 2.11.0-entrypoint-54-g9ff8b0068
Target: Linux-x86_64-Debug
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_BACKTRACE=ON
Compiler: /usr/bin/cc /usr/bin/c++
C_FLAGS: -fexceptions -funwind-tables -fno-common -fopenmp -msse2 -std=c11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-gnu-alignof-expression -fno-gnu89-inline -Wno-cast-function-type -Werror
CXX_FLAGS: -fexceptions -funwind-tables -fno-common -fopenmp -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-invalid-offsetof -Wno-gnu-alignof-expression -Wno-cast-function-type -Werror

Steps to reproduce

tarantool> dt2 = datetime.now()                                              
---           
...
                                      
tarantool> dt = { year = 1, month = 5, day = 17 }                            
---
...        

tarantool> dt2 = datetime.now()                                              
---
...

tarantool> sub_dt = dt2 - dt
---
...

tarantool> add_dt = sub_dt + dt
---
...

tarantool> add_dt == dt2
---
- false
...

tarantool> add_dt
---
- 2022-05-18T00:35:39.026203+0300
...

tarantool> dt2
---
- 2022-05-17T18:35:39.026203+0300
...

tarantool> 

Actual behavior

Expression has a wrong result (false).

Expected behavior

Expression should have a correct result (true).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.