<commit_before>module TomtomWebfleetConnect
  module Models
    class TomtomDate

      attr_accessor :range_pattern, :rangefrom_string, :rangeto_string, :year, :month, :day,
                    :datetime, :hour, :minute, :second

      public

      module RANGE_PATTERN
        ALL = [
            ['today', TODAY = 'd0'],
            ['Yesterday', YESTERDAY = 'd-1'],
            ['Two days ago', TWO_DAY_AGO = 'd-2'],
            ['Three days ago', THREE_DAY_AGO = 'd-3'],
            ['Four days ago', FOUR_DAY_AGO = 'd-4'],
            ['Five days ago', FIVE_DAY_AGO = 'd-5'],
            ['Six days ago', SIX_DAY_AGO = 'd-6'],
            ['Current week', CURRENT_WEEk = 'w0'],
            ['Last week', LAST_WEEK = 'w-1'],
            ['Two weeks ago', TWO_WEEKS_AGO = 'w-2'],
            ['Three weeks ago', THREE_WEEKS_AGO = 'w-3'],
            ['Floating week, current day and previous seven days', TODAY_AND_PREVIOUS_WEEK = 'wf0'],
            ['Floating week, the seven calendar days before wf0', ONE_WEEK_BEFORE_TODAY_AND_PREVIOUS_WEEK = 'wf-1'],
            ['Floating week, the seven calendar days before wf-1', TWO_WEEK_BEFORE_TODAY_AND_PREVIOUS_WEEK = 'wf-2'],
            ['Floating week, the seven calendar days before wf-2', THREE_WEEK_BEFORE_TODAY_AND_PREVIOUS_WEEK = 'wf-3'],
            ['Current month', CURRENT_MONTH = 'm0'],
            ['Last month', LAST_MONTH = 'm-1'],
            ['Two months ago', TWO_MONTH_AGO = 'm-2'],
            ['Three months ago', THREE_MONTH_AGO = 'm-3'],
            ['User-defined range', USER_DEFINED_RANGE = 'ud']
        ]
      end

      def initialize(params = {})

        if params.blank?
          @range_pattern = RANGE_PATTERN::TODAY
          @year= DateTime.now.year
          @month= DateTime.now.month
          @day= DateTime.now.day
          @datetime = DateTime.new(Date.today.year,Date.today.month,Date.today.day,DateTime.now.hour,DateTime.now.minute,DateTime.now.second,'+1')
        # elsif not params[:range_pattern].present?
        #   @year = params[:year].to_i if params[:year].present?
        #   @month = params[:month].to_i if params[:month].present?
        #   @day = params[:day].to_i if params[:day].present?
        #
        #   @range_pattern = RANGE_PATTERN::USER_DEFINED_RANGE
        #   @rangefrom_string = "#{params[:year]}-#{params[:month]}-#{params[:day]}T00 : 00 : 00"
        #   @rangeto_string = "#{params[:year]}-#{params[:month]}-#{params[:day]}T23 : 59 : 59"

        else
          @range_pattern = params[:range_pattern] if params[:range_pattern].present?
          @rangefrom_string = params[:rangefrom_string] if params[:rangefrom_string].present?
          @rangeto_string = params[:rangeto_string] if params[:rangeto_string].present?

          @year = params[:year].to_i if params[:year].present?
          @month = params[:month].to_i if params[:month].present?
          @day = params[:day].to_i if params[:day].present?

          @hour = params[:hour].to_i if params[:hour].present?
          @minute = params[:minute].to_i if params[:minute].present?
          @second = params[:second].to_i if params[:second].present?

          @datetime = DateTime.new(@year,@month,@day,@hour,@minute,@second,'+1')
        end

      end

      # ______________________________________________________
      # CLASS METHOD
      # ______________________________________________________

      def self.today
        TomtomDate.new
      end

      def self.current_month
        TomtomDate.new({range_pattern: RANGE_PATTERN::CURRENT_MONTH})
      end<commit_msg>Change name method today to now<commit_after>module TomtomWebfleetConnect
  module Models
    class TomtomDate

      attr_accessor :range_pattern, :rangefrom_string, :rangeto_string, :year, :month, :day,
                    :datetime, :hour, :minute, :second

      public

      module RANGE_PATTERN
        ALL = [
            ['today', TODAY = 'd0'],
            ['Yesterday', YESTERDAY = 'd-1'],
            ['Two days ago', TWO_DAY_AGO = 'd-2'],
            ['Three days ago', THREE_DAY_AGO = 'd-3'],
            ['Four days ago', FOUR_DAY_AGO = 'd-4'],
            ['Five days ago', FIVE_DAY_AGO = 'd-5'],
            ['Six days ago', SIX_DAY_AGO = 'd-6'],
            ['Current week', CURRENT_WEEk = 'w0'],
            ['Last week', LAST_WEEK = 'w-1'],
            ['Two weeks ago', TWO_WEEKS_AGO = 'w-2'],
            ['Three weeks ago', THREE_WEEKS_AGO = 'w-3'],
            ['Floating week, current day and previous seven days', TODAY_AND_PREVIOUS_WEEK = 'wf0'],
            ['Floating week, the seven calendar days before wf0', ONE_WEEK_BEFORE_TODAY_AND_PREVIOUS_WEEK = 'wf-1'],
            ['Floating week, the seven calendar days before wf-1', TWO_WEEK_BEFORE_TODAY_AND_PREVIOUS_WEEK = 'wf-2'],
            ['Floating week, the seven calendar days before wf-2', THREE_WEEK_BEFORE_TODAY_AND_PREVIOUS_WEEK = 'wf-3'],
            ['Current month', CURRENT_MONTH = 'm0'],
            ['Last month', LAST_MONTH = 'm-1'],
            ['Two months ago', TWO_MONTH_AGO = 'm-2'],
            ['Three months ago', THREE_MONTH_AGO = 'm-3'],
            ['User-defined range', USER_DEFINED_RANGE = 'ud']
        ]
      end

      def initialize(params = {})

        if params.blank?
          @range_pattern = RANGE_PATTERN::TODAY
          @year= DateTime.now.year
          @month= DateTime.now.month
          @day= DateTime.now.day
          @datetime = DateTime.new(Date.today.year,Date.today.month,Date.today.day,DateTime.now.hour,DateTime.now.minute,DateTime.now.second,'+1')
        # elsif not params[:range_pattern].present?
        #   @year = params[:year].to_i if params[:year].present?
        #   @month = params[:month].to_i if params[:month].present?
        #   @day = params[:day].to_i if params[:day].present?
        #
        #   @range_pattern = RANGE_PATTERN::USER_DEFINED_RANGE
        #   @rangefrom_string = "#{params[:year]}-#{params[:month]}-#{params[:day]}T00 : 00 : 00"
        #   @rangeto_string = "#{params[:year]}-#{params[:month]}-#{params[:day]}T23 : 59 : 59"

        else
          @range_pattern = params[:range_pattern] if params[:range_pattern].present?
          @rangefrom_string = params[:rangefrom_string] if params[:rangefrom_string].present?
          @rangeto_string = params[:rangeto_string] if params[:rangeto_string].present?

          @year = params[:year].to_i if params[:year].present?
          @month = params[:month].to_i if params[:month].present?
          @day = params[:day].to_i if params[:day].present?

          @hour = params[:hour].to_i if params[:hour].present?
          @minute = params[:minute].to_i if params[:minute].present?
          @second = params[:second].to_i if params[:second].present?

          @datetime = DateTime.new(@year,@month,@day,@hour,@minute,@second,'+1')
        end

      end

      # ______________________________________________________
      # CLASS METHOD
      # ______________________________________________________

      def self.now
        TomtomDate.new
      end

      def self.current_month
        TomtomDate.new({range_pattern: RANGE_PATTERN::CURRENT_MONTH})
      end
{'fraction_non_alphanumeric': 0.14158056408824352, 'fraction_numerical': 0.01005305780508238, 'mean_word_length': 2.6031187122736417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3100962', 'n_tokens_mistral': 2395, 'n_tokens_neox': 2237, 'n_words': 452}