Sha256: e9e6147a5438bef6b5e3a2b1f3a32127b9917ee81a29ce1f5a5357956d9511cf
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require_relative 'time' require_relative 'time_mneumonic' require_relative 'time_mneumonics' module Dsu module Support module CommandOptions module DsuTimes include Time include TimeMneumonic include TimeMneumonics # Returns an array of Time objects. The first element is the from time. The second element is the to time. # Both arguments are expected to be command options that are time strings, time or relative time mneumonics. def dsu_times_from!(from_command_option:, to_command_option:) times = begin from_time = time_from_mneumonic(command_option: from_command_option) if time_mneumonic?(from_command_option) from_time ||= time_from_date_string(command_option: from_command_option) to_time = time_from_mneumonic(command_option: to_command_option) if time_mneumonic?(to_command_option) to_time ||= time_from_date_string(command_option: to_command_option) [from_time, to_time].sort end (times.min.to_date..times.max.to_date).map(&:to_time) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dsu-1.1.0.alpha.1 | lib/dsu/support/command_options/dsu_times.rb |