Class: HaystackRuby::Timestamp
- Inherits:
-
Object
- Object
- HaystackRuby::Timestamp
- Defined in:
- lib/haystack_ruby/timestamp.rb
Class Method Summary collapse
-
.convert_to_string(ts, tz) ⇒ Object
convert ts to a Project Haystack compliant string.
Class Method Details
.convert_to_string(ts, tz) ⇒ Object
convert ts to a Project Haystack compliant string. ts is a timestamp, tz is a Haystack timezone string for now assumes application timezone is set correctly TODO add a mapping between Ruby and Haystack timezone strings and use here
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/haystack_ruby/timestamp.rb', line 7 def self.convert_to_string ts, tz if ts.kind_of? DateTime t = ts.to_s elsif ts.kind_of? Integer t = Time.at(ts).to_datetime.to_s elsif ts.kind_of? Date t = ts.to_datetime.to_s else raise HaystackRuby::Error, "param must be one of Date, DateTime, Integer" end "#{t} #{tz}" end |