import { EastFunction, TimeUnit } from '../functions'; import { DateTimeType, FloatType, IntegerType, NullType, Nullable, StringType } from '../types'; import { Expression } from './core'; /** * Construct a datetime value from a string, with optional format. * * @param value the string {@link Expression} to parse * @param format the format string (by default it expects ISO-8601, e.g. 'YYYY-MM-DDThh:mm:ss.sssZ') * * @category Expression * * @example * ```typescript * // ... * // parse the date from the US-formated date string * Date: ToDateTime('DateString', 'M-D-YYYY'), * // ... * ``` */ export declare function ToDateTime(value: EastFunction, format?: string): EastFunction>; /** * Find the duration between datetimes `start` and `stop`, in the given time `unit`. Note: * returns a negative number if `stop` is prior to `start` (and that the ordering of * arguments is reversed compared to {@link Subtract}). * * @param start the {@link Expression} for the initial datetime * @param stop the {@link Expression} for the final datetime * @param unit the {@link TimeUnit} to calculate the answer in ('millisecond', 'second', 'minute', 'hour', 'day' or 'week') * * @category Expression * * @example * ```typescript * // ... * // return the length of a shift in hours * ShiftHours: Duration( * Variable('ShiftStart', DateTimeType), * Variable('ShiftStop', DateTimeType), * 'hour' * ), * // ... * ``` */ export declare function Duration(start: EastFunction, stop: EastFunction, unit: TimeUnit): EastFunction : U extends NullType ? Nullable : FloatType>; /** * Add the `duration` (in the given time `unit`) to `datetime`. * * @category Expression * * @param datetime the {@link Expression} for the initial datetime * @param duration the {@link Expression} for duration * @param unit the {@link TimeUnit} of `duration` ('millisecond', 'second', 'minute', 'hour', 'day' or 'week') * * @example * ```typescript * // ... * // return the date payment is due for an invoice according to the invoice terms * DueDate: AddDuration( * Variable('PurchaseDate', DateTimeType), * Variable('InvoiceTermDays', FloatType), * 'day' * ), * // ... * ``` */ export declare function AddDuration(datetime: EastFunction, duration: Expression, unit: TimeUnit): EastFunction : U extends NullType ? Nullable : DateTimeType>; export declare function AddDuration(datetime: EastFunction, duration: Expression, unit: TimeUnit): EastFunction : U extends NullType ? Nullable : DateTimeType>; /** * Subtract the `duration` (in the given time `unit`) from `datetime`. * * @category Expression * * @param datetime the {@link Expression} for the initial datetime * @param duration the {@link Expression} for duration * @param unit the {@link TimeUnit} of `duration` ('millisecond', 'second', 'minute', 'hour', 'day' or 'week') * * @example * ```typescript * // ... * // return the date payment is due for an invoice according to the invoice terms * DueDate: SubtractDuration( * Variable('PurchaseDate', DateTimeType), * Variable('InvoiceTermDays', FloatType), * 'day' * ), * // ... * ``` */ export declare function SubtractDuration(datetime: EastFunction, duration: Expression, unit: TimeUnit): EastFunction : U extends NullType ? Nullable : DateTimeType>; export declare function SubtractDuration(datetime: EastFunction, duration: Expression, unit: TimeUnit): EastFunction : U extends NullType ? Nullable : DateTimeType>; /** * Convert the `datetime` from `input_timezone` to `output_timezone`. * * Note: all datetimes in East are plain (or "naive") datetimes and conversion should take * place using this function. Absolute durations should be calculated in UTC * (zone 'Etc/UTC') to account for e.g. day-light-saving changeovers. The list of IANA * timezone strings can be found at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. * * @param datetime the {@link Expression} for the input datetime * @param input_timezone the {@link Expression} for the input's timezone (as an IANA timezone string) * @param output_timezone the {@link Expression} for the output's timezone (as an IANA timezone string) * * @category Expression * * @example * ```typescript * // ... * // convert the UTC time into Sydney, Australia time * LocalTime: ConvertTimeZone( * Variable('UtcTime', DateTimeType), * 'Etc/UTC', * 'Australia/Sydney' * ), * // ... * ``` */ export declare function TimeZoneConvert(datetime: EastFunction, input_timezone: EastFunction | string, output_timezone: EastFunction | string): EastFunction; /** * Return the number of whole milliseconds elapsed since the start of the second (0 - 999). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function Millisecond(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the number of whole seconds elapsed since the start of the minute (0 - 59). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function Second(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the number of whole minutes elapsed since the start of the hour (0 - 59). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function Minute(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the number of whole hours elapsed since the start of the day (0 - 23). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function Hour(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the number of whole days elapsed since the start of the week (Monday = 0, ..., Sunday = 6). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function DayOfWeek(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the day number of the month (1 - 31). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function DayOfMonth(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the month number of the year (January = 1, ..., December = 12). * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function Month(datetime: EastFunction): EastFunction : IntegerType>; /** * Return the number of whole years since 0AD. * * @param datetime the {@link Expression} for datetime * * @category Expression */ export declare function Year(datetime: EastFunction): EastFunction : IntegerType>;