Sha256: 2a330c86070f72074115afb420733d6d6852d20aadb737c96d973713f2e7112d

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

# frozen_string_literal: true

require_relative "date_converter_ja/version"

module DateConverterJa
  class Error < StandardError; end

  def time_with_ampm
    self.strftime("#{ampm} %H:%M")
  end

  def time_without_ampm
    self.strftime("%H:%M")
  end

  def date_and_time_with_ampm
    self.strftime("%Y/%m/%d(%a) #{ampm} %H:%M")
  end

  def date_and_time_without_ampm
    self.strftime("%Y/%m/%d(%a) %H:%M")
  end

  private def ampm
    case self.hour
    when 12
      '昼'
    when 0
      '深夜'
    when 1..11
      '午前'
    when 13..23
      '午後'
    else
      raise 'Unpredicted time.'
    end
  end
end

class Date
  include DateConverterJa
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
date_converter_ja-0.1.1 lib/date_converter_ja.rb