igniteui-angular
Version:
Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps
124 lines (123 loc) • 6.39 kB
TypeScript
import { DatePartInfo } from '../../directives/date-time-editor/date-time-editor.common';
import { ValidationErrors } from '@angular/forms';
import { DataType } from '../../data-operations/data-util';
/** @hidden */
declare const enum AmPmValues {
AM = "AM",
A = "a",
PM = "PM",
P = "p"
}
/** @hidden */
export declare abstract class DateTimeUtil {
static readonly DEFAULT_INPUT_FORMAT = "MM/dd/yyyy";
static readonly DEFAULT_TIME_INPUT_FORMAT = "hh:mm tt";
private static readonly SEPARATOR;
private static readonly DEFAULT_LOCALE;
/**
* Parse a Date value from masked string input based on determined date parts
*
* @param inputData masked value to parse
* @param dateTimeParts Date parts array for the mask
*/
static parseValueFromMask(inputData: string, dateTimeParts: DatePartInfo[], promptChar?: string): Date | null;
/** Parse the mask into date/time and literal parts */
static parseDateTimeFormat(mask: string, locale?: string): DatePartInfo[];
/** Simplifies the AmPm part to as many chars as will be displayed */
private static simplifyAmPmFormat;
static getPartValue(value: Date, datePartInfo: DatePartInfo, partLength: number): string;
/** Returns the AmPm part value depending on the part length and a
* conditional expression indicating whether the value is AM or PM.
*/
static getAmPmValue(partLength: number, isAm: boolean): AmPmValues;
/** Returns true if a string value indicates an AM period */
static isAm(value: string): boolean;
/** Returns true if a string value indicates a PM period */
static isPm(value: string): boolean;
/** Builds a date-time editor's default input format based on provided locale settings and data type. */
static getDefaultInputFormat(locale: string, dataType?: DataType): string;
/** Tries to format a date using Angular's DatePipe. Fallbacks to `Intl` if no locale settings have been loaded. */
static formatDate(value: number | Date, format: string, locale: string, timezone?: string): string;
/**
* Returns the date format based on a provided locale.
* Supports Angular's DatePipe format options such as `shortDate`, `longDate`.
*/
static getLocaleDateFormat(locale: string, displayFormat?: string): string;
/** Determines if a given character is `d/M/y` or `h/m/s`. */
static isDateOrTimeChar(char: string): boolean;
/** Spins the date portion in a date-time editor. */
static spinDate(delta: number, newDate: Date, spinLoop: boolean): void;
/** Spins the month portion in a date-time editor. */
static spinMonth(delta: number, newDate: Date, spinLoop: boolean): void;
/** Spins the year portion in a date-time editor. */
static spinYear(delta: number, newDate: Date): void;
/** Spins the hours portion in a date-time editor. */
static spinHours(delta: number, newDate: Date, spinLoop: boolean): void;
/** Spins the minutes portion in a date-time editor. */
static spinMinutes(delta: number, newDate: Date, spinLoop: boolean): void;
/** Spins the seconds portion in a date-time editor. */
static spinSeconds(delta: number, newDate: Date, spinLoop: boolean): void;
/** Spins the fractional seconds (milliseconds) portion in a date-time editor. */
static spinFractionalSeconds(delta: number, newDate: Date, spinLoop: boolean): void;
/** Spins the AM/PM portion in a date-time editor. */
static spinAmPm(newDate: Date, currentDate: Date, amPmFromMask: string): Date;
/**
* Determines whether the provided value is greater than the provided max value.
*
* @param includeTime set to false if you want to exclude time portion of the two dates
* @param includeDate set to false if you want to exclude the date portion of the two dates
* @returns true if provided value is greater than provided maxValue
*/
static greaterThanMaxValue(value: Date, maxValue: Date, includeTime?: boolean, includeDate?: boolean): boolean;
/**
* Determines whether the provided value is less than the provided min value.
*
* @param includeTime set to false if you want to exclude time portion of the two dates
* @param includeDate set to false if you want to exclude the date portion of the two dates
* @returns true if provided value is less than provided minValue
*/
static lessThanMinValue(value: Date, minValue: Date, includeTime?: boolean, includeDate?: boolean): boolean;
/**
* Validates a value within a given min and max value range.
*
* @param value The value to validate
* @param minValue The lowest possible value that `value` can take
* @param maxValue The largest possible value that `value` can take
*/
static validateMinMax(value: Date, minValue: Date | string, maxValue: Date | string, includeTime?: boolean, includeDate?: boolean): ValidationErrors;
/** Parse an ISO string to a Date */
static parseIsoDate(value: string): Date | null;
/**
* Returns whether the input is valid date
*
* @param value input to check
* @returns true if provided input is a valid date
*/
static isValidDate(value: any): value is Date;
static isFormatNumeric(locale: string, inputFormat: string): boolean;
/**
* Returns an input format that can be used by the date-time editors, as
* - if the format is already numeric, return it as is
* - if it is among the predefined numeric ones, return it as the equivalent locale-based format
* for the corresponding numeric date parts
* - otherwise, return an empty string
*/
static getNumericInputFormat(locale: string, format: string): string;
/** Gets the locale-based format from an array of date parts */
private static getLocaleInputFormatFromParts;
private static addCurrentPart;
private static daysInMonth;
private static trimEmptyPlaceholders;
private static getMask;
private static logMissingLocaleSettings;
private static prependValue;
private static toTwelveHourFormat;
private static ensureLeadingZero;
private static getCleanVal;
private static determineDatePart;
private static getFormatOptions;
private static getDefaultLocaleMask;
private static getDateStructFromParts;
private static fillDatePartsPositions;
}
export {};