Sha256: 932063e014faffa7a0f8706fe52f490de9cefdf05fb2f5d0dd09efa664d1c39e

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 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)
      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

2 entries across 2 versions & 1 rubygems

Version Path
common_core_js-0.3.6 lib/common_core_js.rb
common_core_js-0.3.5 lib/common_core_js.rb