Sha256: 5d8b5c30942425e87d7c44644d4db806432c43e2d3b732d2f0b0dff222deb222

Contents?: true

Size: 587 Bytes

Versions: 125

Compression:

Stored size: 587 Bytes

Contents

# frozen_string_literal: true

class ReeDatetime::SecondsDiff
  include Ree::FnDSL

  fn :seconds_diff do
    link :round_helper, from: :ree_number, import: -> { ROUND_MODES }
  end


  doc("Returns time difference in seconds")
  contract(
    Or[Date, DateTime, Time],
    Or[Date, DateTime, Time],
    Ksplat[
      round_mode?: Or[*ROUND_MODES]
    ] => Integer).throws(ArgumentError)
  def call(start_time, end_time, **opts)
    s_delta = end_time.to_time.to_i - start_time.to_time.to_i
    raise ArgumentError, "start_time bigger than end_time" if s_delta < 0
    s_delta
  end
end

Version data entries

125 entries across 125 versions & 1 rubygems

Version Path
ree_lib-1.1.0 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.124 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.123 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.122 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.121 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.120 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.119 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.118 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.117 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.116 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.115 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.114 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.113 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.112 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.111 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.110 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.109 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.108 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.107 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb
ree_lib-1.0.106 lib/ree_lib/packages/ree_datetime/package/ree_datetime/functions/seconds_diff.rb