Class: DateTime

Inherits:
Object show all
Defined in:
lib/jinx/helpers/pretty_print.rb

Instance Method Summary collapse

Instance Method Details

#pretty_print(q) ⇒ String

Pretty-prints the DateTime strftime to the given queue in the format dateThrhmmmsss, e.g. 2010-10-10T04h10m30.

Parameters:

  • q

    the print queue

Returns:

  • (String)

    the formatted date and time

Technology idiosyncracy:

  • JRuby

    pp standard libary bug - Printing the formatted date:time string sporadically results in a corrupted line, e.g.:

    at top level in 2010-10-10T00:00:00-07:00 at line 1
    

    The Jinx work-around is to substitute the colons with h, m and s and omit the GMT offset. The bug cause is unknown. Perhaps it is a flaw in the line break logic.



196
197
198
# File 'lib/jinx/helpers/pretty_print.rb', line 196

def pretty_print(q)
  q.text(strftime.sub(/T(\d{2}):(\d{2}):(\d{2})-\d{2}:\d{2}/, 'T\1h\2m\3s'))
end