Sha256: c338da5e6001a1dacfd79d712e7056e3fe581d28cf3c26b16647361dcbc11bcd

Contents?: true

Size: 654 Bytes

Versions: 2

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require 'time'

# Internal: This module is used to parse date_time strings returned by the
# Trivia Crack API.
module TriviaCrack
  module Parsers
    module TimeParser
      TIME_FORMAT = '%m/%d/%Y %H:%M:%S'

      # Internal: Parses a date_time string returned by the Trivia Crack API.
      #
      # raw_data - The date_time string.
      #
      # Examples
      #
      #   TriviaCrack::Parsers::TimeParser.parse "02/17/2015 21:47:19 EST"
      #
      # Returns a Time object representation of the given string.
      def self.parse(raw_data)
        Time.strptime(raw_data, TIME_FORMAT)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
triviacrack-0.8.0 lib/triviacrack/parsers/time_parser.rb
triviacrack-0.7.0 lib/triviacrack/parsers/time_parser.rb