forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The patch adds interval [1] support for datetime. Except encoding/decoding interval values from MessagePack, it adds a several functions for addition and substraction Interval and Datetime types in GoLang. Reproducing, thus, arithmetic operations from the Lua implementation [2]. 1. https://github.com/tarantool/tarantool/wiki/Datetime-Internals#interval-arithmetic 2. https://github.com/tarantool/tarantool/wiki/Datetime-Internals#arithmetic-operations Closes #165
- Loading branch information
1 parent
913bf30
commit ab1fb93
Showing
10 changed files
with
980 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package datetime | ||
|
||
// An Adjust is used as a parameter for date adjustions, see: | ||
// https://github.com/tarantool/tarantool/wiki/Datetime-Internals#date-adjustions-and-leap-years | ||
type Adjust int | ||
|
||
const ( | ||
NoneAdjust Adjust = 0 // adjust = "none" in Tarantool | ||
ExcessAdjust Adjust = 1 // adjust = "excess" in Tarantool | ||
LastAdjust Adjust = 2 // adjust = "last" in Tarantool | ||
) | ||
|
||
// We need the mappings to make NoneAdjust as a default value instead of | ||
// dtExcess. | ||
const ( | ||
dtExcess = 0 // DT_EXCESS from dt-c/dt_arithmetic.h | ||
dtLimit = 1 // DT_LIMIT | ||
dtSnap = 2 // DT_SNAP | ||
) | ||
|
||
var adjustToDt = map[Adjust]int64{ | ||
NoneAdjust: dtLimit, | ||
ExcessAdjust: dtExcess, | ||
LastAdjust: dtSnap, | ||
} | ||
|
||
var dtToAdjust = map[int64]Adjust{ | ||
dtExcess: ExcessAdjust, | ||
dtLimit: NoneAdjust, | ||
dtSnap: LastAdjust, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.