Sha256: 5ef820f7fa5dc4f31db60c03934f97c454c75b621eab3afffb719a69d9b11af7

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true
# Create where clauses for time periods and authorities.
module QaServer
  class TimeService
    class << self
      # @return [ActiveSupport::TimeWithZone] current DateTime in the configured preferred_time_zone_name
      def current_time
        Time.now.in_time_zone(QaServer.config.preferred_time_zone_name)
      end

      # @return [Float] current DateTime in seconds
      def current_time_s
        current_time.to_f
      end

      # @param dt [ActiveSupport::TimeWithZone] date time stamp
      # @return [String] string version of date formatted with date and time (e.g. "02/01/2020 - 02:35 PM ET")
      def pretty_time(dt)
        dt.in_time_zone(QaServer.config.preferred_time_zone_name).strftime("%m/%d/%Y - %I:%M %p")
      end

      # @param dt [ActiveSupport::TimeWithZone] date time stamp
      # @return [String] string version of date formatted with just date (e.g. "02/01/2020")
      def pretty_date(dt)
        dt.in_time_zone(QaServer.config.preferred_time_zone_name).strftime("%m/%d/%Y")
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
qa_server-7.8.0 app/services/qa_server/time_service.rb
qa_server-7.7.1 app/services/qa_server/time_service.rb
qa_server-7.7.0 app/services/qa_server/time_service.rb
qa_server-7.6.0 app/services/qa_server/time_service.rb
qa_server-7.5.1 app/services/qa_server/time_service.rb
qa_server-7.5.0 app/services/qa_server/time_service.rb
qa_server-7.4.0 app/services/qa_server/time_service.rb
qa_server-7.3.0 app/services/qa_server/time_service.rb
qa_server-7.2.1 app/services/qa_server/time_service.rb
qa_server-7.2.0 app/services/qa_server/time_service.rb
qa_server-7.1.3 app/services/qa_server/time_service.rb
qa_server-7.1.2 app/services/qa_server/time_service.rb
qa_server-7.1.1 app/services/qa_server/time_service.rb
qa_server-7.1.0 app/services/qa_server/time_service.rb
qa_server-7.0.0 app/services/qa_server/time_service.rb
qa_server-6.2.0 app/services/qa_server/time_service.rb
qa_server-6.1.0 app/services/qa_server/time_service.rb
qa_server-6.0.0 app/services/qa_server/time_service.rb