@storm-stack/date-time
Version:
This package includes a DateTime class, various utility functions for working with dates and times, and a number of formatting options.
116 lines (115 loc) • 3.98 kB
TypeScript
import { Temporal } from "@js-temporal/polyfill";
import { type JsonValue } from "@storm-stack/serialization";
import { ValidationDetails } from "@storm-stack/types";
import type { DateTimeInput, DateTimeOptions } from "./storm-date-time";
import { StormDateTime } from "./storm-date-time";
/**
* Serializes a StormDate into a string
*
* @param date - The date to serialize
* @returns The serialized date
*/
export declare function serializeStormDate(date: StormDate): string;
/**
* Deserializes a string into a StormDate
*
* @param utcString - The date to deserialize
* @returns The deserialized date
*/
export declare function deserializeStormDate(utcString: JsonValue): StormDate;
/**
* A wrapper of the and Date class used by Storm Software to provide Date-Time values
*
* @decorator `@Serializable()`
* @class StormDate
*/
declare class StormDate extends StormDateTime {
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
static now(): number;
/**
* The current function returns a new DateTime object with the current date and time
* @returns A new instance of DateTime with the current date and time.
*/
static current(): StormDate;
/**
* The maximum function returns a new StormDateTime object with the maximum date and time
*
* @returns A new instance of StormDateTime with the maximum date and time.
*/
static minimum(): StormDate;
/**
* The maximum function returns a new StormDateTime object with the maximum date and time
*
* @returns A new instance of StormDateTime with the maximum date and time.
*/
static maximum(): StormDate;
/**
* Validate the input date value
*
* @param dateTime - The date value to validate
* @returns A boolean representing whether the value is a valid *date-time*
*/
static validate(value?: DateTimeInput): ValidationDetails | null;
/**
* Creates a new StormDate object with the given date and time
*
* @param date - The date to use
* @param options - The options to use
* @returns A new instance of DateTime with the given date and time.
*/
static create(date?: DateTimeInput, options?: DateTimeOptions): StormDate;
constructor(dateTime?: DateTimeInput, options?: DateTimeOptions);
/**
* A function that validates the current Date object
*
* @returns A ValidationDetails object if the Date object is invalid, otherwise null
*/
validate(): ValidationDetails | null;
/**
* Gets the hours in a date, using local time.
*/
getHours(): number;
/**
* Gets the hours value in a Date object using Universal Coordinated Time (UTC).
*/
getUTCHours(): number;
/**
* Gets the minutes of a Date object, using local time.
*/
getMinutes(): number;
/**
* Gets the minutes of a Date object using Universal Coordinated Time (UTC).
*/
getUTCMinutes(): number;
/**
* Gets the seconds of a Date object, using local time.
*/
getSeconds(): number;
/**
* Gets the seconds of a Date object using Universal Coordinated Time (UTC).
*/
getUTCSeconds(): number;
/**
* Gets the milliseconds of a Date, using local time.
*/
getMilliseconds(): number;
/**
* Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
*/
getUTCMilliseconds(): number;
/**
* Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC).
*/
getTimezoneOffset(): number;
/**
* It returns the duration between two dates.
*
* @param dateTimeTo - DateTime = DateTime.current
* @returns A duration object.
*/
getDuration(dateTimeTo?: StormDateTime): Temporal.Duration;
}
export { StormDate };