Class: Transit::WriteHandlers::TimeHandler
- Inherits:
-
Object
- Object
- Transit::WriteHandlers::TimeHandler
show all
- Defined in:
- lib/transit/write_handlers.rb
Overview
TimeHandler, DateTimeHandler, and DateHandler all have different
implementations of string_rep. Here is the rationale:
For all three, want to write out the same format
e.g. 2014-04-18T18:51:29.478Z, and we want the milliseconds to truncate
rather than round, eg 29.4786 seconds should be 29.478, not 29.479.
Some data points (see benchmarks/encoding_time.rb)
- Time and DateTime each offer iso8601 methods, but strftime is faster.
- DateTime's strftime (and iso8601) round millis
- Time's strftime (and iso8601) truncate millis
- we don't care about truncate v round for dates (which have 000 ms)
- date.to_datetime.strftime(...) is considerably faster than date.to_time.strftime(...)
Instance Method Summary
collapse
Instance Method Details
#string_rep(t) ⇒ Object
293
|
# File 'lib/transit/write_handlers.rb', line 293
def string_rep(t) rep(t).to_s end
|
#tag(_) ⇒ Object
291
|
# File 'lib/transit/write_handlers.rb', line 291
def tag(_) "m" end
|
#verbose_handler ⇒ Object
294
|
# File 'lib/transit/write_handlers.rb', line 294
def verbose_handler() VerboseTimeHandler.new end
|