gnablib
Version:
A lean, zero dependency library to provide a useful base for your project.
84 lines (83 loc) • 3.36 kB
TypeScript
/*! Copyright 2024 the gnablib contributors MPL-1.1 */
import { BitWriter } from '../primitive/BitWriter.js';
import { BitReader } from '../primitive/BitReader.js';
import { ISerializer } from '../primitive/interfaces/ISerializer.js';
import { WindowStr } from '../primitive/WindowStr.js';
import { IDurationExactParts, IDurationParts } from './interfaces/IDurationParts.js';
declare const consoleDebugSymbol: unique symbol;
declare abstract class ADurationCore {
protected readonly _storage: Uint8Array;
protected readonly _hPos: number;
protected constructor(_storage: Uint8Array, _hPos: number);
abstract get day(): number;
protected abstract _otherHours(): number;
get hour(): number;
get minute(): number;
get second(): number;
get microsecond(): number;
toString(): string;
toIso8601(): string;
toJSON(): string;
toTimeLike(): string;
serialize(target: BitWriter): void;
protected _validate(): void;
protected _dh_misu(): [number, number];
protected static _loadHISU(h: number, i: number, s: number, u: number, storage: Uint8Array, hPos: number): void;
protected static _convertHISUPartsToUs(parts: IDurationExactParts): number;
protected static _parseDHIS(input: WindowStr): IDurationExactParts;
protected static _deserHISU(source: BitReader, storage: Uint8Array, hPos: number): void;
}
export declare class DurationExact extends ADurationCore implements ISerializer {
static readonly serialBits: number;
static readonly storageBytes: number;
static get zero(): DurationExact;
static get max(): DurationExact;
get day(): number;
protected _otherHours(): number;
toString(): string;
toIso8601(): string;
toDhMiso(): [number, number];
serialize(target: BitWriter): void;
get serialSizeBits(): number;
validate(): DurationExact;
gt(de: DurationExact): boolean;
add(de: DurationExact): DurationExact;
sub(de: DurationExact): DurationExact;
get [Symbol.toStringTag](): string;
[consoleDebugSymbol](): string;
private static _loadDHISU;
static new(parts: IDurationExactParts): DurationExact;
static fromUs(us: number): DurationExact;
static fromTimeLike(timeLike: string): DurationExact;
static parse(input: WindowStr): DurationExact;
static deserialize(source: BitReader): DurationExact;
}
export declare class Duration extends ADurationCore implements ISerializer {
static readonly serialBits: number;
static readonly storageBytes: number;
static get zero(): Duration;
static get max(): Duration;
get year(): number;
get month(): number;
get day(): number;
protected _otherHours(): number;
toString(): string;
toIso8601(): string;
serialize(target: BitWriter): void;
get serialSizeBits(): number;
validate(): Duration;
toYMDhMiso(): [number, number, number, number];
private _ymf_dh_misu;
gt(d: Duration): boolean;
add(d: DurationExact): Duration;
add(d: Duration): Duration;
sub(d: DurationExact): Duration;
sub(d: Duration): Duration;
get [Symbol.toStringTag](): string;
[consoleDebugSymbol](): string;
private static _loadYMfD;
static new(parts: IDurationParts): Duration;
static parse(input: WindowStr): Duration;
static deserialize(source: BitReader): Duration;
}
export {};