Sha256: 662e82362150e241b3bb968ad551b8d37765d0393f61ac4a0c52a0d6168b4b27

Contents?: true

Size: 1.42 KB

Versions: 15

Compression:

Stored size: 1.42 KB

Contents

module Eddy
  module Util
    # Functions for formatting [Time](https://ruby-doc.org/stdlib-2.6.5/libdoc/time/rdoc/Time.html) objects.
    module Time

      # @!group DT

      # Generates an timestamp in `CCYYMMDD` format.
      #
      # @param date [Time] A *UTC* formatted `Time` object.
      # @return [String]
      def self.ccyymmdd(date = Time.now.utc)
        return date.strftime("%Y%m%d")
      end

      # Generates an timestamp in `YYMMDD` format.
      #
      # @param date [Time] A *UTC* formatted `Time` object.
      # @return [String]
      def self.yymmdd(date = Time.now.utc)
        return date.strftime("%y%m%d")
      end

      # @!endgroup DT

      # @!group TM

      # @param time [Time] A *UTC* formatted `Time` object.
      # @return [String]
      def self.hhmm(time = Time.now.utc)
        return time.strftime("%H%M")
      end

      # @param time [Time] A *UTC* formatted `Time` object.
      # @return [String]
      def self.hhmmss(time = Time.now.utc)
        return time.strftime("%H%M%S")
      end

      # @param time [Time] A *UTC* formatted `Time` object.
      # @return [String]
      def self.hhmmssd(time = Time.now.utc)
        return time.strftime("%H%M%S%1N")
      end

      # @param time [Time] A *UTC* formatted `Time` object.
      # @return [String]
      def self.hhmmssdd(time = Time.now.utc)
        return time.strftime("%H%M%S%2N")
      end

      # @!endgroup TM

    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
eddy-0.10.0 lib/eddy/util/time.rb
eddy-0.9.2 lib/eddy/util/time.rb
eddy-0.9.1 lib/eddy/util/time.rb
eddy-0.9.0 lib/eddy/util/time.rb
eddy-0.8.4 lib/eddy/util/time.rb
eddy-0.8.3 lib/eddy/util/time.rb
eddy-0.8.2 lib/eddy/util/time.rb
eddy-0.8.1 lib/eddy/util/time.rb
eddy-0.8.0 lib/eddy/util/time.rb
eddy-0.7.0 lib/eddy/util/time.rb
eddy-0.6.0 lib/eddy/util/time.rb
eddy-0.5.1 lib/eddy/util/time.rb
eddy-0.5.0 lib/eddy/util/time.rb
eddy-0.4.0 lib/eddy/util/time.rb
eddy-0.3.0 lib/eddy/util/time.rb