<commit_before>module Biz
  class DayTime

    module Timestamp
      FORMAT  = '%02d:%02d'
      PATTERN = /\A(?<hour>\d{2}):(?<minute>\d{2})(:?(?<second>\d{2}))?\Z/
    end

    include Comparable

    extend Forwardable

    class << self

      def from_time(time)
        new(
          time.hour * Time::SECONDS_IN_HOUR +
            time.min * Time::SECONDS_IN_MINUTE +
            time.sec
        )
      end

      def from_minute(minute)
        new(minute * Time::SECONDS_IN_MINUTE)
      end

      def from_hour(hour)
        new(hour * Time::SECONDS_IN_HOUR)
      end

      def from_timestamp(timestamp)
        timestamp.match(Timestamp::PATTERN) { |match|
          new(
            match[:hour].to_i * Time::SECONDS_IN_HOUR +
              match[:minute].to_i * Time::SECONDS_IN_MINUTE +
              match[:second].to_i
          )
        }
      end

      def midnight
        MIDNIGHT
      end

      alias_method :am, :midnight

      def noon
        NOON
      end

      alias_method :pm, :noon

      def endnight
        ENDNIGHT
      end

    end

    attr_reader :day_second

    delegate strftime: :day_time

    delegate %i[
      to_i
      to_int
    ] => :day_second

    def initialize(day_second)
      @day_second = Integer(day_second)
    end

    def hour
      day_second / Time::SECONDS_IN_HOUR
    end

    def minute
      day_second % Time::SECONDS_IN_HOUR / Time::SECONDS_IN_MINUTE
    end

    def second
      day_second % Time::SECONDS_IN_MINUTE
    end

    def day_minute
      hour * Time::MINUTES_IN_HOUR + minute
    end

    def for_dst
      self.class.new(
        (day_second + Time::SECONDS_IN_HOUR) % Time::SECONDS_IN_DAY
      )
    end

    def timestamp
      format(Timestamp::FORMAT, hour, minute)
    end

    def coerce(other)
      [self.class.new(other), self]
    end

    protected

    def <=>(other)
      return nil unless other.respond_to?(:to_i)

      day_second <=> other.to_i
    end

    private

    def day_time
      ::Time.new(
        Date::EPOCH.year,
        Date::EPOCH.month,
        Date::EPOCH.mday,
        hour,
        minute,
        second
      )
    end

    MIDNIGHT = from_hour(0)
    NOON     = from_hour(12)
    ENDNIGHT = from_hour(24)
<commit_msg>Improve name for formatting-focused time<commit_after>module Biz
  class DayTime

    module Timestamp
      FORMAT  = '%02d:%02d'
      PATTERN = /\A(?<hour>\d{2}):(?<minute>\d{2})(:?(?<second>\d{2}))?\Z/
    end

    include Comparable

    extend Forwardable

    class << self

      def from_time(time)
        new(
          time.hour * Time::SECONDS_IN_HOUR +
            time.min * Time::SECONDS_IN_MINUTE +
            time.sec
        )
      end

      def from_minute(minute)
        new(minute * Time::SECONDS_IN_MINUTE)
      end

      def from_hour(hour)
        new(hour * Time::SECONDS_IN_HOUR)
      end

      def from_timestamp(timestamp)
        timestamp.match(Timestamp::PATTERN) { |match|
          new(
            match[:hour].to_i * Time::SECONDS_IN_HOUR +
              match[:minute].to_i * Time::SECONDS_IN_MINUTE +
              match[:second].to_i
          )
        }
      end

      def midnight
        MIDNIGHT
      end

      alias_method :am, :midnight

      def noon
        NOON
      end

      alias_method :pm, :noon

      def endnight
        ENDNIGHT
      end

    end

    attr_reader :day_second

    delegate strftime: :format_time

    delegate %i[
      to_i
      to_int
    ] => :day_second

    def initialize(day_second)
      @day_second = Integer(day_second)
    end

    def hour
      day_second / Time::SECONDS_IN_HOUR
    end

    def minute
      day_second % Time::SECONDS_IN_HOUR / Time::SECONDS_IN_MINUTE
    end

    def second
      day_second % Time::SECONDS_IN_MINUTE
    end

    def day_minute
      hour * Time::MINUTES_IN_HOUR + minute
    end

    def for_dst
      self.class.new(
        (day_second + Time::SECONDS_IN_HOUR) % Time::SECONDS_IN_DAY
      )
    end

    def timestamp
      format(Timestamp::FORMAT, hour, minute)
    end

    def coerce(other)
      [self.class.new(other), self]
    end

    protected

    def <=>(other)
      return nil unless other.respond_to?(:to_i)

      day_second <=> other.to_i
    end

    private

    def format_time
      ::Time.new(
        Date::EPOCH.year,
        Date::EPOCH.month,
        Date::EPOCH.mday,
        hour,
        minute,
        second
      )
    end

    MIDNIGHT = from_hour(0)
    NOON     = from_hour(12)
    ENDNIGHT = from_hour(24)

{'fraction_non_alphanumeric': 0.09434792170661975, 'fraction_numerical': 0.0052782054101605455, 'mean_word_length': 1.8108776266996292, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5961117', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1529, 'n_words': 300}