Class: QaServer::TimeService

Inherits:
Object
  • Object
show all
Defined in:
app/services/qa_server/time_service.rb

Class Method Summary collapse

Class Method Details

.current_timeActiveSupport::TimeWithZone

Returns current DateTime in the configured preferred_time_zone_name.

Returns:

  • (ActiveSupport::TimeWithZone)

    current DateTime in the configured preferred_time_zone_name



7
8
9
# File 'app/services/qa_server/time_service.rb', line 7

def current_time
  Time.now.in_time_zone(QaServer.config.preferred_time_zone_name)
end

.current_time_sFloat

Returns current DateTime in seconds.

Returns:

  • (Float)

    current DateTime in seconds



12
13
14
# File 'app/services/qa_server/time_service.rb', line 12

def current_time_s
  current_time.to_f
end

.pretty_date(dt) ⇒ String

Returns string version of date formatted with just date (e.g. “02/01/2020”).

Parameters:

  • dt (ActiveSupport::TimeWithZone)

    date time stamp

Returns:

  • (String)

    string version of date formatted with just date (e.g. “02/01/2020”)



24
25
26
# File 'app/services/qa_server/time_service.rb', line 24

def pretty_date(dt)
  dt.in_time_zone(QaServer.config.preferred_time_zone_name).strftime("%m/%d/%Y")
end

.pretty_time(dt) ⇒ String

Returns string version of date formatted with date and time (e.g. “02/01/2020 - 02:35 PM ET”).

Parameters:

  • dt (ActiveSupport::TimeWithZone)

    date time stamp

Returns:

  • (String)

    string version of date formatted with date and time (e.g. “02/01/2020 - 02:35 PM ET”)



18
19
20
# File 'app/services/qa_server/time_service.rb', line 18

def pretty_time(dt)
  dt.in_time_zone(QaServer.config.preferred_time_zone_name).strftime("%m/%d/%Y - %I:%M %p")
end