<commit_before>package de.finetech.groovy.utils.datatypes;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import de.abas.eks.jfop.FOPException;
import de.abas.eks.jfop.remote.FO;
import de.finetech.groovy.AbasBaseScript;
import de.finetech.groovy.utils.GroovyFOException;
import de.finetech.groovy.utils.GroovyFOVariable;

public class AbasDate extends GroovyFOVariable<String> {

	private AbasBaseScript script;

	private int DATE = 0, DAY_OF_WEEK = 1, NAME = 2;

	private static Pattern pattern = Pattern
			.compile("\\bGD\\b|\\bGD0\\b|\\bGD2\\b|\\bGD7\\b|\\bGD8\\b|\\bGD13\\b|\\bGD14\\b|\\bGD19\\b|\\bGD20\\b|"
					+ "\\bGW2\\b|\\bGW4\\b|"
					+ "\\bZ\\b"
					+ "|\\bJ2\\b|\\bGJ\\b|"
					+ "\\bGP1\\b|\\bGP2\\b|\\bGP3\\b|\\bGP4\\b|"
					+ "\\bDATUM\\b|\\bWOCHE\\b|\\bTERMIN\\b|\\bZEIT\\b");
	private String[] tempvars = { "xfooaddate", "xfooadweekday",
			"xfooadweekdayname" };

	public static boolean isDate(String type) {
		type = type.toUpperCase();
		Matcher match = pattern.matcher(type);
		return match.find();
	}

	/**
	 * 
	 * @param type
	 *            - abas type bsp.: GD, GD2, ...
	 * @param var
	 *            - Variable mit Puffer! bsp M|von, U|xvon
	 * @param script
	 *            - script welches den abastype anlegt
	 * @throws GroovyFOException
	 */
	public AbasDate(String type, String var, AbasBaseScript script)
			throws GroovyFOException {
		super(var, script);
		this.script = script;
		this.type = type;
		this.tempvars[DATE] = this.script.art(this.type, tempvars[DATE] + type);
		this.tempvars[DAY_OF_WEEK] = this.script.art("INT",
				tempvars[DAY_OF_WEEK]);
		this.tempvars[NAME] = this.script.art("TEXT", tempvars[NAME]);
		if (!AbasDate.isDate(type))
			throw new GroovyFOException(type
					+ " is not a abas datetype for date/time/duration");
	}

	// FIXME GD19+GP = GD19 usw siehe hilfe

	public Object plus(int i) throws FOPException, GroovyFOException {
		return this.script.formel(tempvars[0], this.getVariablename() + " + "
				+ i);
	}

	public Object next() throws FOPException, GroovyFOException {
		return this.script.formel(this.getVariablename(),
				this.getVariablename() + " + " + 1);
	}

	public Object previous() throws FOPException, GroovyFOException {
		return this.script.formel(this.getVariablename(),
				this.getVariablename() + " -1 " + 1);
	}

	public Object minus(int i) throws FOPException, GroovyFOException {
		return this.plus(-i);<commit_msg>Berechnung für  abasdate hinzugefügt<commit_after>package de.finetech.groovy.utils.datatypes;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import de.abas.eks.jfop.FOPException;
import de.abas.eks.jfop.remote.FO;
import de.finetech.groovy.AbasBaseScript;
import de.finetech.groovy.utils.GroovyFOException;
import de.finetech.groovy.utils.GroovyFOVariable;

public class AbasDate extends GroovyFOVariable<String> {

	private AbasBaseScript script;

	private int DATE = 0, DAY_OF_WEEK = 1, NAME = 2;

	private static Pattern pattern = Pattern
			.compile("\\bGD\\b|\\bGD0\\b|\\bGD2\\b|\\bGD7\\b|\\bGD8\\b|\\bGD13\\b|\\bGD14\\b|\\bGD19\\b|\\bGD20\\b|"
					+ "\\bGW2\\b|\\bGW4\\b|"
					+ "\\bZ\\b"
					+ "|\\bJ2\\b|\\bGJ\\b|"
					+ "\\bGP1\\b|\\bGP2\\b|\\bGP3\\b|\\bGP4\\b|"
					+ "\\bDATUM\\b|\\bWOCHE\\b|\\bTERMIN\\b|\\bZEIT\\b");
	private String[] tempvars = { "xfooaddate", "xfooadweekday",
			"xfooadweekdayname" };

	public static boolean isDate(String type) {
		type = type.toUpperCase();
		Matcher match = pattern.matcher(type);
		return match.find();
	}

	/**
	 * 
	 * @param type
	 *            - abas type bsp.: GD, GD2, ...
	 * @param var
	 *            - Variable mit Puffer! bsp M|von, U|xvon
	 * @param script
	 *            - script welches den abastype anlegt
	 * @throws GroovyFOException
	 */
	public AbasDate(String type, String var, AbasBaseScript script)
			throws GroovyFOException {
		super(var, script);
		this.script = script;
		this.type = type;
		this.tempvars[DATE] = this.script.art(this.type, tempvars[DATE] + type);
		this.tempvars[DAY_OF_WEEK] = this.script.art("INT",
				tempvars[DAY_OF_WEEK]);
		this.tempvars[NAME] = this.script.art("TEXT", tempvars[NAME]);
		if (!AbasDate.isDate(type))
			throw new GroovyFOException(type
					+ " is not a abas datetype for date/time/duration");
	}

	// FIXME GD19+GP = GD19 usw siehe hilfe

	public Object plus(int i) throws FOPException, GroovyFOException {
		return this.script.formel(tempvars[DATE], this.getVariablename() + " + "
				+ i);
	}

	public Object next() throws FOPException, GroovyFOException {
		return this.script.formel(this.getVariablename(),
				this.getVariablename() + " + " + 1);
	}

	public Object previous() throws FOPException, GroovyFOException {
		return this.script.formel(this.getVariablename(),
				this.getVariablename() + " -1 " + 1);
	}

	public Object minus(int i) throws FOPException, GroovyFOException {
		return this.plus(-i);
	}
	
	/**
	 * abasdate - abasdate
	 * @param i
	 * @return
	 * @throws FOPException
	 * @throws GroovyFOException
	 */
	public Object minus(AbasDate i) throws FOPException, GroovyFOException {
		return script.formel(tempvars[DATE], this.getVariablename() +"-"+i.getVariablename());
	}
	
	/**
	 *  abasdate + abasdate
	 * @param i
	 * @return
	 * @throws FOPException
	 * @throws GroovyFOException
	 */
	public Object plus(AbasDate i) throws FOPException, GroovyFOException {
		return script.formel(tempvars[DATE], this.getVariablename() +"+"+i.getVariablename());
{'fraction_non_alphanumeric': 0.15866617808721142, 'fraction_numerical': 0.011176255038475632, 'mean_word_length': 3.4024193548387096, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1081553', 'n_tokens_mistral': 2293, 'n_tokens_neox': 2020, 'n_words': 380}