Source: Date_lib/process.js

import("system.translate");
import("system.datetime");

/**
 * provides methods for interactions with dates
 */
function DateUtils(){
    
    var that = this;
    /**
     * Validates two date inputs (beginning should always be before the end!)
     * 
     * @param pStart {Number}
     * @param pEnd {Number}
     * 
     * @result {Boolean|null} Boolean if it was able to check smth or null if the input values were not valid
     */
    this.validateBeginnBeforeEnd = function(pStart, pEnd) {
        if (pStart == "" || pStart == null || pEnd == "" || pEnd == null) return null;
        return pStart <= pEnd;
    }
    
    this.getValidationFailString = function(){
        return translate.text("The expiry date must be after the start date!");
    }
    
    /**
     * Delivers the current date at midnight in UTC
     * 
     * @result {Number} 
     */
    this.getTodayUTC = function(){
        return datetime.today("UTC");
    }
    
    /**
     * Delivers the passed date incremented by passed years
     * 
     * @param pDate {Number}
     * @param pYears {Number}
     * 
     * @result {Number} date incremented by years
     */
    this.getDateIncrementedByYears = function(pDate, pYears){
        var dateObj = new Date(pDate);
        
        return dateObj.setFullYear(dateObj.getFullYear() + pYears);
    }
}