Module: Avro::LogicalTypes::TimestampNanos
- Defined in:
- lib/avro/logical_types.rb
Constant Summary collapse
- SUBUNITS_PER_SECOND =
1000_000_000
Class Method Summary collapse
Class Method Details
.decode(int) ⇒ Object
258 259 260 261 |
# File 'lib/avro/logical_types.rb', line 258 def self.decode(int) s, ns = int.divmod(SUBUNITS_PER_SECOND) Time.at(s, ns, :nanosecond).utc end |
.encode(value) ⇒ Object
251 252 253 254 255 256 |
# File 'lib/avro/logical_types.rb', line 251 def self.encode(value) return value.to_i if value.is_a?(Numeric) time = value.to_time time.to_i * SUBUNITS_PER_SECOND + time.nsec end |