Skip to content

Commit

Permalink
lua, datetime: time intervals support
Browse files Browse the repository at this point in the history
* created few entry points (months(N), years(N), days(N), etc.)
  for easier datetime arithmetic;
* additions/subtractions of years/months use `dt_add_years()`
  and `dt_add_months()` from 3rd party c-dt library;
* also there are `:add{}` and `:sub{}` methods in datetime
  object to add or substract more complex intervals;
* introduced `is_datetime()` and `is_interval()` helpers for checking
  of validity of passed arguments;
* human-readable stringization implemented for interval objects.

Note, that additions/subtractions completed for all _reasonable_
combinations of values of date and interval types;

	Time + Interval	=> Time
	Interval + Time => Time
	Time - Time 	=> Interval
	Time - Interval => Time
	Interval + Interval => Interval
	Interval - Interval => Interval

Part of tarantool#5941
  • Loading branch information
tsafin committed Jul 27, 2021
1 parent 84f652a commit 79ddb27
Show file tree
Hide file tree
Showing 3 changed files with 655 additions and 96 deletions.
3 changes: 3 additions & 0 deletions src/exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ EXPORT(uuid_nil)
EXPORT(uuid_unpack)
EXPORT(datetime_unpack)
EXPORT(datetime_pack)
EXPORT(dt_add_months)
EXPORT(dt_add_years)
EXPORT(dt_add_quarters)
EXPORT(dt_from_rdn)
EXPORT(dt_from_yd)
EXPORT(dt_from_ymd)
Expand Down
Loading

0 comments on commit 79ddb27

Please sign in to comment.