@bmqube/xmlrpc
Version:
A pure TypeScript XML-RPC client and server. Forked from (https://github.com/baalexander/node-xmlrpc)
57 lines (56 loc) • 1.84 kB
text/typescript
export interface DateFormatterOptions {
colons: boolean;
hyphens: boolean;
local: boolean;
ms: boolean;
offset: boolean;
}
/**
* @class DateFormatter
* The DateFormatter supports decoding from and encoding to
* ISO8601 formatted strings. Accepts formats with and without
* hyphen/colon separators and correctly parses zoning info.
*/
export declare class DateFormatter {
opts: DateFormatterOptions;
constructor(opts?: Partial<DateFormatterOptions>);
/**
* Default options for DateFormatter
*/
static readonly DEFAULT_OPTIONS: DateFormatterOptions;
/**
* Regular Expression that dissects ISO 8601 formatted strings into parts.
*/
static readonly ISO8601: RegExp;
/**
* Sets options for encoding Date objects to ISO8601 strings.
* Omitting the 'opts' argument will reset all options to the default.
*/
setOpts(opts?: Partial<DateFormatterOptions>): void;
/**
* Converts ISO8601 string to a Date.
*/
decodeIso8601(time: string): Date;
/**
* Converts a Date to ISO8601 string using current options.
*/
encodeIso8601(date: Date): string;
/**
* UTC parts (YYYY, MM, DD, hh, mm, ss, mmm) with zero-padding where needed.
*/
static getUTCDateParts(date: Date): (string | number)[];
/**
* Local parts (YYYY, MM, DD, hh, mm, ss, mmm) with zero-padding where needed.
*/
static getLocalDateParts(date: Date): (string | number)[];
/**
* Left-pad a number with zeros to the specified length.
*/
static zeroPad(digit: number, length: number): string;
/**
* Returns timezone offset in "Z" or "+/-HH:MM" form (for the given date or now).
*/
static formatCurrentOffset(d?: Date): string;
}
declare const dateFormatter: DateFormatter;
export default dateFormatter;