32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/advance.rb', line 32
def call(date_time, **opts)
changed_date = advance(
date_time.to_date,
**slice(opts, [:years, :months, :quarters, :weeks, :days])
)
datetime_advanced_by_date = change(
date_time,
year: changed_date.year,
month: changed_date.month,
day: changed_date.day
)
seconds_to_advance = (opts[:seconds] || 0) + (opts[:minutes] ||0) * 60 + (opts[:hours] || 0) * 3600
if seconds_to_advance.zero?
datetime_advanced_by_date
else
datetime_advanced_by_date = seconds_since(
datetime_advanced_by_date, seconds_to_advance
)
end
end
|