Sha256: 6f46a6739b91f96f906ca01ba14dc61e0e764ade42587c2224f1e4078402b2d4
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
module ActiveRecord module ConnectionAdapters module SQLServer module Type module TimeValueFractional private def cast_fractional(value) return value if !value.respond_to?(fractional_property) || value.send(fractional_property).zero? seconds = value.send(fractional_property).to_f / fractional_operator.to_f seconds = ((seconds * (1 / fractional_precision)).round / (1 / fractional_precision)).round(fractional_scale) frac_seconds = (seconds * fractional_operator).to_i value.change fractional_property => frac_seconds end def quote_fractional(value) seconds = (value.send(fractional_property).to_f / fractional_operator.to_f).round(fractional_scale) seconds.to_s.split('.').last.to(fractional_scale-1) end def fractional_property :usec end def fractional_digits 6 end def fractional_operator 10 ** fractional_digits end def fractional_precision 0.00333 end def fractional_scale 3 end end module TimeValueFractional2 include TimeValueFractional private def fractional_property :nsec end def fractional_digits 9 end def fractional_precision 0.0000001 end def fractional_scale precision end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems