<commit_before>module IceCube

  class IcalBuilder

    # TODO verify
    ICAL_DAYS = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']

    def initialize
      @hash = {}
    end

    def self.fixnum_to_ical_day(num)
      ICAL_DAYS[num]
    end

    def [](key)
      @hash[key] ||= []
    end

    # Build for a single rule entry
    # TODO always take FREQ first
    def to_s
      @hash.map do |key, value|
        if value.is_a?(Array)
          "#{key}=#{value.join(',')}"
        end
      end.compact.join(';')
    end

    def self.ical_utc_format(time)
      time = time.dup.utc
      "#{time.strftime('%Y%m%dT%H%M%SZ')}" # utc time
    end

    def self.ical_format(time, force_utc)
      time = time.dup.utc if force_utc
      if time.utc?
        ":#{time.strftime('%Y%m%dT%H%M%SZ')}" # utc time
      else
        ";TZID=#{time.strftime('%Z:%Y%m%dT%H%M%S')}" # local time specified
      end
    end

    def self.ical_duration(duration)
      hours = duration / 3600; duration %= 3600
      minutes = duration / 60; duration %= 60
      repr = ''
      repr << "#{hours}H" if hours > 0
      repr << "#{minutes}M" if minutes > 0
      repr << "#{duration}S" if duration > 0
      "PT#{repr}"
    end

  end

end
<commit_msg>FREQ always first<commit_after>module IceCube

  class IcalBuilder

    # TODO verify
    ICAL_DAYS = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']

    def initialize
      @hash = {}
    end

    def self.fixnum_to_ical_day(num)
      ICAL_DAYS[num]
    end

    def [](key)
      @hash[key] ||= []
    end

    # Build for a single rule entry
    def to_s
      arr = []
      if freq = @hash.delete('FREQ')
        arr << "FREQ=#{freq.join(',')}"
      end
      arr.concat(@hash.map do |key, value|
        if value.is_a?(Array)
          "#{key}=#{value.join(',')}"
        end
      end.compact)
      arr.join(';')
    end

    def self.ical_utc_format(time)
      time = time.dup.utc
      "#{time.strftime('%Y%m%dT%H%M%SZ')}" # utc time
    end

    def self.ical_format(time, force_utc)
      time = time.dup.utc if force_utc
      if time.utc?
        ":#{time.strftime('%Y%m%dT%H%M%SZ')}" # utc time
      else
        ";TZID=#{time.strftime('%Z:%Y%m%dT%H%M%S')}" # local time specified
      end
    end

    def self.ical_duration(duration)
      hours = duration / 3600; duration %= 3600
      minutes = duration / 60; duration %= 60
      repr = ''
      repr << "#{hours}H" if hours > 0
      repr << "#{minutes}M" if minutes > 0
      repr << "#{duration}S" if duration > 0
      "PT#{repr}"
    end

  end

end

{'fraction_non_alphanumeric': 0.16393442622950818, 'fraction_numerical': 0.0117096018735363, 'mean_word_length': 2.1180048661800486, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 9, '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': '2106779', 'n_tokens_mistral': 1028, 'n_tokens_neox': 975, 'n_words': 221}