Sha256: ba681d1427e696b279f7580a08df39d1aa2e6520e6112d32ff34db8a09bd1ea5

Contents?: true

Size: 869 Bytes

Versions: 11

Compression:

Stored size: 869 Bytes

Contents

module Hyperstack
  module Internal
    class I18n
      module HelperMethods
        def formatted_date_or_time(date_or_time)
          # If the date_or_time parameter is a String, we must parse it to the correct format.

          return date_or_time unless date_or_time.is_a?(String)

          if date_or_time =~ /^\d+\W\d+\W\d+T?\s?\d+:\d+:\d+/
            Time.parse(date_or_time)
          else
            Date.parse(date_or_time)
          end
        end

        def formatted_format(format)
          # If a string is passed in it will use that as the pattern for formatting, ex:
          #
          # I18n.l(Time.now, format: "%b %d, %Y")
          # => "Aug 20, 2017"
          #
          # If a symbol is passed in it will find that definition from the locales.

          format =~ /%/ ? format : :"#{format}"
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
hyper-i18n-1.0.alpha1.8 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.7 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.6 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.5 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.4 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.3 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.2 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1.1 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.0.pre.alpha1 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.alpha1 lib/hyperstack/internal/i18n/helper_methods.rb
hyper-i18n-1.0.pre.alpha1 lib/hyperstack/internal/i18n/helper_methods.rb