timezonecomplete
Version:
DateTime, TimeZone, Duration and Period library aimed at providing a consistent and complete date-time interface, away from the original JavaScript Date class.
45 lines (44 loc) • 1.71 kB
TypeScript
/**
* Copyright(c) 2014 ABB Switzerland Ltd.
*
* Functionality to parse a DateTime object to a string
*/
import { TimeStruct } from "./basics";
import { PartialLocale } from "./locale";
import { TimeZone } from "./timezone";
/**
* TimeStruct plus zone
*/
export interface AwareTimeStruct {
/**
* The time struct
*/
time: TimeStruct;
/**
* The time zone (can be undefined)
*/
zone: TimeZone | undefined;
}
/**
* Checks if a given datetime string is according to the given format
* @param dateTimeString The string to test
* @param formatString LDML format string (see LDML.md)
* @param allowTrailing Allow trailing string after the date+time
* @param locale Locale-specific constants such as month names
* @returns true iff the string is valid
* @throws nothing
*/
export declare function parseable(dateTimeString: string, formatString: string, allowTrailing?: boolean, locale?: PartialLocale): boolean;
/**
* Parse the supplied dateTime assuming the given format.
*
* @param dateTimeString The string to parse
* @param formatString The formatting string to be applied
* @param overrideZone Use this zone in the result
* @param allowTrailing Allow trailing characters in the source string
* @param locale Locale-specific constants such as month names
* @return string
* @throws timezonecomplete.ParseError if the given dateTimeString is wrong or not according to the pattern
* @throws timezonecomplete.Argument.FormatString if the given format string is invalid
*/
export declare function parse(dateTimeString: string, formatString: string, overrideZone?: TimeZone | null | undefined, allowTrailing?: boolean, locale?: PartialLocale): AwareTimeStruct;