Module: Avro::LogicalTypes::TimestampMicros
- Defined in:
- lib/avro/logical_types.rb
Constant Summary collapse
- SUBUNITS_PER_SECOND =
1000_000
Class Method Summary collapse
Class Method Details
.decode(int) ⇒ Object
242 243 244 245 |
# File 'lib/avro/logical_types.rb', line 242 def self.decode(int) s, us = int.divmod(SUBUNITS_PER_SECOND) Time.at(s, us, :microsecond).utc end |
.encode(value) ⇒ Object
235 236 237 238 239 240 |
# File 'lib/avro/logical_types.rb', line 235 def self.encode(value) return value.to_i if value.is_a?(Numeric) time = value.to_time time.to_i * SUBUNITS_PER_SECOND + time.usec end |