@uplink-protocol/calendar-controller
Version:
Flexible calendar API supporting both calendar and date-picker integrations for any JavaScript framework or library
69 lines (68 loc) • 2.38 kB
TypeScript
import { IDateFormattingService } from '../interfaces/date-formatting.service.interfaces';
import { ILocalizationService } from '../interfaces/localization.service.interfaces';
/**
* Implementation of DateFormattingService
* Responsible for formatting dates
*/
export declare class DateFormattingService implements IDateFormattingService {
private _defaultFormat;
private _localizationService;
private _dateFormatOptions;
/**
* Set the localization service
* @param service Localization service to use
*/
setLocalizationService(service: ILocalizationService): void;
/**
* Get the localization service
* @returns Current localization service or null
*/
getLocalizationService(): ILocalizationService | null;
/**
* Set the date format options for Intl.DateTimeFormat
* @param options Format options
*/
setDateFormatOptions(options: Intl.DateTimeFormatOptions): void;
/**
* Get the date format options
* @returns Current date format options or null
*/
getDateFormatOptions(): Intl.DateTimeFormatOptions | null; /**
* Format a date according to the specified format string
* @param date Date to format
* @param format Optional format string or format type ('short', 'medium', 'long', 'full')
* @returns Formatted date string
*/
formatDate(date: Date, format?: string | Intl.DateTimeFormatOptions): string;
/**
* Parse a date string according to the specified format
* @param dateString Date string to parse
* @param format Optional format string
* @returns Parsed Date or null if invalid
*/
parseDate(dateString: string, format?: string): Date | null;
/**
* Set the default date format
* @param format Format string
*/
setDefaultFormat(format: string): void;
/**
* Get the default date format
* @returns Default format or null
*/
getDefaultFormat(): string | null;
/**
* Format a month and year
* @param year Year to format
* @param month Month to format (0-11)
* @param format Optional format string
* @returns Formatted month string
*/
formatMonth(year: number, month: number, format?: string): string;
/**
* Format a year
* @param year Year to format
* @returns Formatted year string
*/
formatYear(year: number): string;
}