@alfresco/adf-core
Version:
85 lines (84 loc) • 3.43 kB
TypeScript
/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export declare class DateFnsUtils {
static getLocaleFromString(locale: string): Locale;
private static momentToDateFnsMap;
/**
* Converts a Moment.js date format string to the equivalent date-fns format string.
*
* @param dateDisplayFormat - The Moment.js date format string to convert.
* @returns The equivalent date-fns format string.
*/
static convertMomentToDateFnsFormat(dateDisplayFormat: string): string;
/**
* Formats a date using the specified date format.
*
* @param date - The date to format, can be a number or a Date object.
* @param dateFormat - The date format string to use for formatting.
* @returns The formatted date as a string
*/
static formatDate(date: number | Date | string, dateFormat: string): string;
/**
* Parses a date string using the specified date format.
*
* @param value - The date value to parse. Can be a string or a Date (for generic calls)
* @param dateFormat - The date format string to use for parsing.
* @param options - Additional options
* @param options.dateOnly - Strip the time and zone
* @returns The parsed Date object.
*/
static parseDate(value: string | Date, dateFormat: string, options?: {
dateOnly?: boolean;
}): Date;
/**
* Parses a datetime string using the ISO format
*
* @param value - The date and time string to parse
* @returns returns the parsed Date object
*/
static parseDateTime(value: string): Date;
/**
* Checks if the date string is a valid date according to the specified format
*
* @param dateValue Date value
* @param dateFormat The date format
* @returns `true` if the date is valid, otherwise `false`
*/
static isValidDate(dateValue: string, dateFormat: string): boolean;
/**
* Validates a date is before another one
*
* @param source source date to compare
* @param target target date to compare
* @returns `true` if the source date is before the target one, otherwise `false`
*/
static isBeforeDate(source: Date, target: Date): boolean;
/**
* Validates a date is after another one
*
* @param source source date to compare
* @param target target date to compare
* @returns `true` if the source date is after the target one, otherwise `false`
*/
static isAfterDate(source: Date, target: Date): boolean;
static utcToLocal(date: Date): Date;
static localToUtc(date: Date): Date;
static forceLocal(date: Date | string): Date;
static forceUtc(date: Date | string): Date;
static stringDateContainsTimeZone(value: string): boolean;
static getDate(value: string | number | Date): Date;
}