Class: QaServer::TimeService
- Inherits:
-
Object
- Object
- QaServer::TimeService
- Defined in:
- app/services/qa_server/time_service.rb
Class Method Summary collapse
-
.current_time ⇒ ActiveSupport::TimeWithZone
Current DateTime in the configured preferred_time_zone_name.
-
.current_time_s ⇒ Float
Current DateTime in seconds.
-
.pretty_date(dt) ⇒ String
String version of date formatted with just date (e.g. “02/01/2020”).
-
.pretty_time(dt) ⇒ String
String version of date formatted with date and time (e.g. “02/01/2020 - 02:35 PM ET”).
Class Method Details
.current_time ⇒ ActiveSupport::TimeWithZone
Returns 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_s ⇒ Float
Returns 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”).
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”).
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 |