Sha256: ea179f2b9467d1a89c7d7117abc1de60beb322c83b10afe0718c69e5f0674490

Contents?: true

Size: 693 Bytes

Versions: 12

Compression:

Stored size: 693 Bytes

Contents

require "common_core_js/engine"

require 'kaminari'
require 'haml-rails'


module CommonCoreJs
  # Your code goes here...
  #
  module ControllerHelpers
    def modify_date_inputs_on_params(modified_params, authenticated_user = nil)
      use_timezone = authenticated_user.timezone || Time.now.strftime("%z")

      modified_params = modified_params.tap do |params|
        params.keys.each{|k|
          if k.ends_with?("_at") || k.ends_with?("_date")

            begin
              params[k] = DateTime.strptime("#{params[k]} #{use_timezone}", '%Y-%m-%dT%H:%M %z')
            rescue StandardError

            end
          end
        }
      end
      modified_params
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
common_core_js-0.4.7 lib/common_core_js.rb
common_core_js-0.4.6 lib/common_core_js.rb
common_core_js-0.4.4 lib/common_core_js.rb
common_core_js-0.4.3 lib/common_core_js.rb
common_core_js-0.4.2 lib/common_core_js.rb
common_core_js-0.4.1 lib/common_core_js.rb
common_core_js-0.4.0 lib/common_core_js.rb
common_core_js-0.3.9 lib/common_core_js.rb
common_core_js-0.3.8 lib/common_core_js.rb
common_core_js-0.3.7 lib/common_core_js.rb
common_core_js-0.3.4 lib/common_core_js.rb
common_core_js-0.3.3 lib/common_core_js.rb