<commit_before>package edu.ucsc.sil.fixcache.util;

import org.joda.time.DateTime;
import org.joda.time.Minutes;
import org.joda.time.Months;
import org.joda.time.Weeks;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.lang.StringBuilder;

public class Dates {
    
    static final DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    static StringBuilder range;

	public static DateTime toDateTime(String date){
	    
	    return fmt.parseDateTime(date);
	}
	
	public static String toString(DateTime date)
	{
	    return date.toString(fmt);
	}

	public static int getMinuteDuration(String start, String end)
	{
	    return Minutes.minutesBetween(toDateTime(start), toDateTime(end)).getMinutes();
	}
	
	public static int getMonthDuration(String start, String end)
	
	{
	    int mo =  Months.monthsBetween(toDateTime(start), toDateTime(end)).getMonths();
	    return mo;
	}

	public static int getWeekDuration(String start, String end)
	{
	    return Weeks.weeksBetween(toDateTime(start), toDateTime(end)).getWeeks();
	}

	
	public static String monthsLater(String start, int numMonths)
	{
	    return toString(toDateTime(start).plusMonths(numMonths));
	}
	
	   public static String weeksLater(String start, int numMonths)
	    {
	        return toString(toDateTime(start).plusWeeks(numMonths));
	    }
	
	public static void main(String args[])
	{
	    DateTime d = new DateTime("2000-05-04T01:02:03");
	    System.out.print(toString(d));
	}

	public static String getRange(String rangeStart, String rangeEnd) {
		DateTime start = toDateTime(rangeStart);
		DateTime end = toDateTime(rangeEnd);
		range = new StringBuilder();
		range.append(start.getYear());
		range.append(".");
		range.append(start.getMonthOfYear());
		range.append(".");
		range.append(start.getDayOfMonth());
		range.append("~");
		range.append(end.getYear());
		range.append(".");
		range.append(end.getMonthOfYear());
		range.append(".");
		range.append(end.getDayOfMonth());
		return range.toString();
	}<commit_msg>use two different DateTime format for mysql and sqlite.<commit_after>package edu.ucsc.sil.fixcache.util;

import org.joda.time.DateTime;
import org.joda.time.Minutes;
import org.joda.time.Months;
import org.joda.time.Weeks;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.lang.StringBuilder;

public class Dates {

    static StringBuilder range;
    public enum dbtype{mysql, sqlite};

    static final DateTimeFormatter mysqlfmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.S");
    static final DateTimeFormatter sqlitefmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    
    private static DateTimeFormatter fmt;

    public static void initializeFormat(dbtype type){
        if(fmt==null) {
            switch (type){
            case mysql: fmt = mysqlfmt;break;
            case sqlite: fmt = sqlitefmt;break;      
            }  
        }
    }


    // must first call initializeFormat
    public static DateTime toDateTime(String date){
        assert (fmt != null);
        return fmt.parseDateTime(date);
    }

    // must first call initializeFormat
    public static String toString(DateTime date)
    {
        assert (fmt != null);
        return date.toString(fmt);
    }

    public static int getMinuteDuration(String start, String end)
    {
        return Minutes.minutesBetween(toDateTime(start), toDateTime(end)).getMinutes();
    }

    public static int getMonthDuration(String start, String end)

    {
        int mo =  Months.monthsBetween(toDateTime(start), toDateTime(end)).getMonths();
        return mo;
    }

    public static int getWeekDuration(String start, String end)
    {
        return Weeks.weeksBetween(toDateTime(start), toDateTime(end)).getWeeks();
    }


    public static String monthsLater(String start, int numMonths)
    {
        return toString(toDateTime(start).plusMonths(numMonths));
    }

    public static String weeksLater(String start, int numMonths)
    {
        return toString(toDateTime(start).plusWeeks(numMonths));
    }

    public static void main(String args[])
    {
        DateTime d = new DateTime("2000-05-04T01:02:03");
        System.out.print(toString(d));
    }

    public static String getRange(String rangeStart, String rangeEnd) {
        DateTime start = toDateTime(rangeStart);
        DateTime end = toDateTime(rangeEnd);
        range = new StringBuilder();
        range.append(start.getYear());
        range.append(".");
        range.append(start.getMonthOfYear());
        range.append(".");
        range.append(start.getDayOfMonth());
        range.append("~");
        range.append(end.getYear());
        range.append(".");
        range.append(end.getMonthOfYear());
        range.append(".");
        range.append(end.getDayOfMonth());
        return range.toString();
    }
{'fraction_non_alphanumeric': 0.11929967426710097, 'fraction_numerical': 0.005700325732899023, 'mean_word_length': 3.390527256478999, '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': '6023593', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1419, 'n_words': 316}