Sha256: 856e5b5986b4700b1b0cc3c07f87e96c95d4056d1f308e4222d66aa42c57f286

Contents?: true

Size: 530 Bytes

Versions: 20

Compression:

Stored size: 530 Bytes

Contents

# frozen_string_literal: true

require 'date'

DateTime.class_eval do
  # @return [String] - mm/dd/yyyy HH:MM:SS AM/PM or m/d/yy HH:MM:SS AM/PM
  def display_user(all = false)
    strftime(all ? '%m/%d/%Y %r' : '%-m/%-d/%y %r')
  end
end

Time.class_eval do
  # @return [String] - mm/dd/yyyy or m/d/yy
  def display_user(all = false)
    to_datetime.display_user(all)
  end
end

Date.class_eval do
  # @return [String] - mm/dd/yyyy or m/d/yy
  def display_user(all = false)
    strftime(all ? '%m/%d/%Y' : '%-m/%-d/%y')
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ruby-rails-extensions-2.1.1 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.14 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.13 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.12 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.11 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.10 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.9 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.8 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.7 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.6 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.5 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.4 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.3 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.2 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.1.0.pre.rc.1 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.0.1 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.0.1.pre.rc.1 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.0.0 lib/ruby-rails-extensions/extensions/display_user.rb
ruby-rails-extensions-2.0.0.pre.rc.1 lib/ruby-rails-extensions/extensions/display_user.rb