license import { TranslationWidth } from '../i18n/type' ; export abstract class DateService < D > { static DAYS_IN_WEEK : number = 7 ; static MONTHS_IN_YEAR : number = 12 ; protected locale : string ; public setLocale ( locale ) { this . locale = locale ; } public compareDatesSafe ( date1 , date2 ) { if ( date1 && date2 ) { return this . compareDates ( date1 , date2 ) ; } else if ( ! date1 && ! date2 ) { return 0 ; } return - 1 ; } /**
     * Checks if the date is between the start date and the end date.
     * */ public isBetween ( date , start , end ) { return this . compareDates ( date , start ) > 0 && this . compareDates ( date , end ) < 0 ; } /**
     * Checks if the date is between the start date and the end date.
     * */ public isBetweenSafe ( date , start , end ) { return date && start && end && this . compareDates ( date , start ) > 0 && this . compareDates ( date , end ) < 0 ; } /**
     * Checks if the date is between the start date and the end date including bounds.
     * */ public isBetweenIncluding ( date , start , end ) { return this . compareDates ( date , start ) >= 0 && this . compareDates ( date , end ) <= 0 ; } /**
     * Checks if the date is between the start date and the end date including bounds.
     * */ public isBetweenIncludingSafe ( date , start , end ) { return date && start && end && this . isBetweenIncluding ( date , start , end ) ; } /**
     * Checks is two dates have the same day.
     * */ public isSameDaySafe ( date1 , date2 ) { return date1 && date2 && this . isSameDay ( date1 , date2 ) ; } /**
     * Checks is two dates have the same month.
     * */ public isSameMonthSafe ( date1 , date2 ) { return date1 && date2 && this . isSameMonth ( date1 , date2 ) ; } /**
     * Checks is two dates have the same year.
     * */ public isSameYearSafe ( date1 , date2 ) { return date1 && date2 && this . isSameYear ( date1 , date2 ) ; } /**
     * Returns true if date string is valid date string according to the provided format.
     * */ public abstract isValidDateString ( date , format ) ; /**
     * Returns today date.
     * */ public abstract today ( ) ; /**
     * Gets the date of the month component of the given date.
     */ public abstract getDate ( date ) ; /**
     * Gets the month component of the given date.
     * */ public abstract getMonth ( date ) ; /**
     * Gets the year component of the given date.
     * */ public abstract getYear ( date ) ; /**
     * Returns day of the week of the given date.
     */ public abstract getDayOfWeek ( date ) ; /**
     * Returns first day of the week, it can be 1 if week starts from monday
     * and 0 if from sunday and so on.
     * */ public abstract getFirstDayOfWeek ( ) ; /**
     * Returns localized month name by date and style.
     * */ public abstract getMonthName ( date , style ? ) ; /**
     * Returns localized month name by month index and style.
     * */ public abstract getMonthNameByIndex ( month , style ? ) ; /**
     * Returns localized days names.
     * */ public abstract getDayOfWeekNames ( style ? ) ; /**
     * Parses the date string according to the passed format.
     * */ public abstract parse ( date , format ) ; /**
     * Transforms the date to the string according to the passed format.
     * */ public abstract format ( date , format ) ; /**
     * Creates new date from year, month and date.
     * */ public abstract createDate ( year , month , date ) ; /**
     * Checks is two dates have the same year.
     * */ public abstract isSameYear ( date1 , date2 ) ; /**
     * Checks is two dates have the same month.
     * */ public abstract isSameMonth ( date1 , date2 ) ; /**
     * Checks is two dates have the same day.
     * */ public abstract isSameDay ( date1 , date2 ) ; /**
     * Compares two dates.
     * Returns 0 if dates are the same.
     * Returns 1 if the first date is greater than the second.
     * Returns -1 if the second date is greater than the first.
     * */ public abstract compareDates ( date1 , date2 ) ; /**
     * Clones passed date.
     * */ public abstract clone ( date ) ; /**
     * Creates the same date but with day equals to 1.
     * */ public abstract getMonthStart ( date ) ; /**
     * Creates the same date but with day equals to the last day in this month.
     * */ public abstract getMonthEnd ( date ) ; /**
     * Creates the same date but with month equals to 0 and day equals to 1.
     * */ public abstract getYearStart ( date ) ; /**
     * Creates the same date but with month equals to 11 and day equals to 31.
     * */ public abstract getYearEnd ( date ) ; /**
     * Returns number of days in the date.
     * */ public abstract getNumberOfDaysInMonth ( date ) ; /**
     * Returns date with added number of days.
     * */ public abstract addDay ( date , days ) ; /**
     * Returns date with added number of months.
     * */ public abstract addMonth ( date , months ) ; /**
     * Returns date with added number of years.
     * */ public abstract addYear ( date , years ) ; public abstract getId ( ) ; }