Module: PactBroker::Api::Decorators::FormatDateTime

Included in:
BaseDecorator, DashboardDecorator, MatrixDecorator, Metrics::Service
Defined in:
lib/pact_broker/api/decorators/format_date_time.rb

Constant Summary collapse

DATE_TIME_CLASS =

Keep this in sync with Sequel.datetime_class. Needs to be upgraded from DateTime to Time as Time is deprecated

DateTime

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(date_time) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/pact_broker/api/decorators/format_date_time.rb', line 9

def self.call(date_time)
  if date_time.is_a?(String)
    Sequel.string_to_datetime(date_time).to_time.utc.to_datetime.xmlschema
  elsif date_time
    date_time.to_time.utc.to_datetime.xmlschema if date_time
  end
end

Instance Method Details

#format_date_time(date_time) ⇒ Object



17
18
19
# File 'lib/pact_broker/api/decorators/format_date_time.rb', line 17

def format_date_time(date_time)
  FormatDateTime.call(date_time)
end