Sha256: b572033ec92eaaab36efeeb24a27367a7ef2d516b3815fc548b40660f940ae27
Contents?: true
Size: 431 Bytes
Versions: 1
Compression:
Stored size: 431 Bytes
Contents
require 'json' require 'json/add/core' class ::Time def as_ms to_i * 1000 + usec / 1000 end def to_json(*_a) # Use the precision provided in our receiver, but only up to milliseconds at max. Objects lacking the fraction part # altogether will be serialized without fraction part using this algorithm. fraction_digits = [nsec.to_s.sub(/0+$/, '').length, 3].min iso8601(fraction_digits).to_json end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecraft-extensions-0.3.1 | lib/ecraft/extensions/time.rb |