27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/couchbase/utils/time.rb', line 27
def (time_or_duration)
if time_or_duration.respond_to?(:in_seconds) time_or_duration.in_seconds
elsif time_or_duration.respond_to?(:tv_sec) time_or_duration.tv_sec
elsif time_or_duration.is_a?(Integer)
if time_or_duration < RELATIVE_EXPIRY_CUTOFF_SECONDS
time_or_duration
elsif time_or_duration > WORKAROUND_EXPIRY_CUTOFF_SECONDS
effective_expiry = ::Time.at(time_or_duration).utc
warn "The specified expiry duration #{time_or_duration} is longer than 50 years. For bug-compatibility " \
"with previous versions of SDK 3.0.x, the number of seconds in the duration will be interpreted as " \
"the epoch second when the document should expire (#{effective_expiry}). Stuffing an epoch second " \
"into a Duration is deprecated and will no longer work in SDK 3.1. Consider using Time instance instead."
time_or_duration
else
::Time.now.tv_sec + time_or_duration
end
else
time_or_duration
end
end
|