<commit_before>/*
 * Copyright (C) 2015-2016 QuickAF
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.ieclipse.af.common;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

public class TimeRange {
    private Calendar start = Calendar.getInstance();
    private Calendar current = Calendar.getInstance();
    private Calendar end = Calendar.getInstance();

    private int yearMin;
    private int yearMax;
    private int yearIdx;

    private int monthMin;
    private int monthMax;
    private int monthIdx;

    private int dayMin;
    private int dayMax;
    private int dayIdx;

    private int hourMin;
    private int hourMax;
    private int hourIdx;

    private int minuteMin;
    private int minuteMax;
    private int minuteIdx;

    public void setStartTime(int field, int value) {
        start.set(field, value);
        init();
    }

    public void setStartTimeRelative(int field, int value) {
        start.add(field, value);
        init();
    }

    public void setStartTime(long time) {
        start.setTime(new Date(time));
    }

    public void setCurrentTime(int field, int value) {
        current.set(field, value);
        init();
    }

    public void setCurrentTime(long time) {
        current.setTime(new Date(time));
        init();
    }

    public void setEndTime(int field, int value) {
        end.set(field, value);
        init();
    }

    public void setEndTimeRelative(int field, int value) {
        end.add(field, value);
        init();
    }

    public void setEndTime(long time) {
        end.setTime(new Date(time));
        init();
    }

    public int[] getYearRange() {
        return new int[]{yearMin, yearMax, yearIdx};
    }

    public int[] getMonthRange() {
        return new int[]{monthMin, monthMax, monthIdx};
    }

    public int[] getDayRange() {
        return new int[]{dayMin, dayMax, dayIdx};
    }

    public int[] getHourRange() {
        return new int[]{hourMin, hourMax, hourIdx};
    }

    private void printRange() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        System.out.println(sdf.format(start.getTime()));
        System.out.println(sdf.format(current.getTime()));
        System.out.println(sdf.format(end.getTime()));

        System.out.println(Arrays.toString(getYearRange()));
        System.out.println(Arrays.toString(getMonthRange()));
        System.out.println(Arrays.toString(getDayRange()));
        System.out.println(Arrays.toString(getHourRange()));
    }

    private void init() {
        System.out.println("init");
        int y1 = start.get(Calendar.YEAR);
        int y2 = end.get(Calendar.YEAR);
        int y = current.get(Calendar.YEAR);

        int m1 = y1 < y ? 0 : start.get(Calendar.MONTH);
        int m2 = y < y2 ? 11 : end.get(Calendar.MONTH);

        int m = current.get(Calendar.MONTH);<commit_msg>add time minute range<commit_after>/*
 * Copyright (C) 2015-2016 QuickAF
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.ieclipse.af.common;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;

public class TimeRange {
    private Calendar start = Calendar.getInstance();
    private Calendar current = Calendar.getInstance();
    private Calendar end = Calendar.getInstance();

    private int yearMin;
    private int yearMax;
    private int yearIdx;

    private int monthMin;
    private int monthMax;
    private int monthIdx;

    private int dayMin;
    private int dayMax;
    private int dayIdx;

    private int hourMin;
    private int hourMax;
    private int hourIdx;

    private int minuteMin;
    private int minuteMax;
    private int minuteIdx;

    public void setStartTime(int field, int value) {
        start.set(field, value);
        init();
    }

    public void setStartTimeRelative(int field, int value) {
        start.add(field, value);
        init();
    }

    public void setStartTime(long time) {
        start.setTime(new Date(time));
    }

    public void setCurrentTime(int field, int value) {
        current.set(field, value);
        init();
    }

    public void setCurrentTime(long time) {
        current.setTime(new Date(time));
        init();
    }

    public void setEndTime(int field, int value) {
        end.set(field, value);
        init();
    }

    public void setEndTimeRelative(int field, int value) {
        end.add(field, value);
        init();
    }

    public void setEndTime(long time) {
        end.setTime(new Date(time));
        init();
    }

    public int[] getYearRange() {
        return new int[]{yearMin, yearMax, yearIdx};
    }

    public int[] getMonthRange() {
        return new int[]{monthMin, monthMax, monthIdx};
    }

    public int[] getDayRange() {
        return new int[]{dayMin, dayMax, dayIdx};
    }

    public int[] getHourRange() {
        return new int[]{hourMin, hourMax, hourIdx};
    }

    public int[] getMinuteRange() {return new int[]{minuteMin, minuteMax, minuteIdx};}

    private void printRange() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        System.out.println(sdf.format(start.getTime()));
        System.out.println(sdf.format(current.getTime()));
        System.out.println(sdf.format(end.getTime()));

        System.out.println(Arrays.toString(getYearRange()));
        System.out.println(Arrays.toString(getMonthRange()));
        System.out.println(Arrays.toString(getDayRange()));
        System.out.println(Arrays.toString(getHourRange()));
    }

    private void init() {
        System.out.println("init");
        int y1 = start.get(Calendar.YEAR);
        int y2 = end.get(Calendar.YEAR);
        int y = current.get(Calendar.YEAR);

        int m1 = y1 < y ? 0 : start.get(Calendar.MONTH);
        int m2 = y < y2 ? 11 : end.get(Calendar.MONTH);

        int m = current.get(Calendar.MONTH);
{'fraction_non_alphanumeric': 0.11217490711631894, 'fraction_numerical': 0.006001714775650186, 'mean_word_length': 2.7608812466415906, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1453543', 'n_tokens_mistral': 2070, 'n_tokens_neox': 1998, 'n_words': 596}