UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

147 lines (146 loc) 9.9 kB
import { CalculateDatesType } from "./types/date.types"; import { Time } from "./types/time.types"; import { DateFormatsType, DateTimeFormatsType } from "../util/types/formatter.types"; /** * @class date * @memberof common */ export declare class DateModule { private vlf; /** * @function getToday * @memberOf common.date * @description Returns the current day in the given format. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getToday("mm/dd/yyyy"); */ getToday(format?: DateFormatsType): Date | string; /** * @function getTomorrow * @memberOf common.date * @description Returns tomorrows date in the given format. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getTomorrow("mm/dd/yyyy"); */ getTomorrow(format?: DateFormatsType): Date | string; /** * @function getNextMonth * @memberOf common.date * @description Returns the current day one month later in the given format. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getNextMonth("mm/dd/yyyy"); */ getNextMonth(format?: DateFormatsType): Date | string; /** * @function getPreviousMonth * @memberOf common.date * @description Returns the current day one month before in the given format. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getPreviousMonth("mm/dd/yyyy"); */ getPreviousMonth(format?: DateFormatsType): Date | string; /** * @function getNextYear * @memberOf common.date * @description Returns the current day one year later in the given format. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getNextYear("mm/dd/yyyy"); */ getNextYear(format?: DateFormatsType): Date | string; /** * @function getPreviousYear * @memberOf common.date * @description Returns the current day one year before in the given format. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getPreviousYear("mm/dd/yyyy"); */ getPreviousYear(format?: DateFormatsType): Date | string; /** * @function getSpecific * @memberOf common.date * @description Returns a specific date in the given format. * @param {String} date - A specific date string. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String} The date in the given format. * @example const date = await common.date.getSpecific("2020, 0, 17", "mm/dd/yyyy"); */ getSpecific(date: string, format?: DateFormatsType): Date | string; /** * @function calculate * @memberOf common.date * @description Calculates the date based on the input parameter and returns it in the given format. * @param {String} [date="today"] - Supported values: "today", "tomorrow", "nextMonth", "previousMonth", "nextYear", "previousYear" * If the date is not provided, "today" will be used. * @param {String} [format="object"] - The expected format ("mm/dd/yyyy", "mm-dd-yyyy", "dd.mm.yyyy", "dd/mm/yyyy", "yyyymmdd", "yyyy/mm/dd", * "yyyy.mm.dd", "yyyy-mm-dd", "dd.mm.yyyy.hh.mm", "mmm dd, yyyy", "mmm d, yyyy", "g.yy.mm.dd", "g/yy/mm/dd", "g-yy-mm-dd" "datetime", "object"). * @returns {String | Date} The calculated date in the given format. * @example const date = await common.date.calculate("today", "mm/dd/yyyy"); */ calculate(date?: CalculateDatesType, format?: DateFormatsType): Date | string; /** * @function getCurrentDateAndTime * @memberOf common.date * @description Returns the current date and time in the given format. * @param {String} [format="object"] - The expected format as a string, which consists of date and time formats, separated by a whitespace or another delimiter. * Supported formats are the same as for the {@link common.date.calculateWithTime} method.<br> * @returns {String | Date} The calculated date and time in the given format. * @example const date = common.date.getCurrentDateAndTime("mm/dd/yyyy HH:mm:ss"); * // returns a string like "06/17/2025 08:17:27" * @example const date = common.date.getCurrentDateAndTime(); * // returns a Date object like "Tue Jun 17 2025 08:17:27 GMT+0200 (Central European Summer Time)" */ getCurrentDateAndTime(format?: DateTimeFormatsType): string | Date; /** * @function calculateWithTime * @memberOf common.date * @description Calculates the date and time based on the input parameter and returns it in the given format. * @param {String} [date = "today"] - Supported values: "today", "tomorrow", "nextMonth", "previousMonth", "nextYear", "previousYear". * @param {String} [time] - The time of day. * Supported formats: "HH:MM:SS" (e.g. "10:30:20"), "HH:MM" (e.g. "10:30"), "HH" (e.g. "10"). * It can also be in 12-hour format with AM/PM (e.g. "10:30 PM", "3 AM"). * It can also be a time anchor, such as "currentTime", "startOfDay", or "endOfDay".<br> * If not provided, the time will default to the "startOfDay". * @param {String} [format="object"] - The expected output format as a string, which consists of <b>date and time formats, separated by a whitespace or another delimiter</b> (such as 'T' substring).<br> * - Supported <b>date</b> formats are the same as for the {@link common.date.calculate} method.<br> * - Supported <b>time</b> formats are the following: "HH\:mm:ss" (24-hour format), "h\:mm:ss a" (12-hour format), "HH\:mm:ss z" (24-hour format with timezone), "h\:mm:ss a z" (12-hour format with timezone), * "HH\:mm" (24-hour format), "h\:mm a" (12-hour format), "HH" (24-hour format), "h a" (12-hour format).<br> * - Examples of <b>expected format</b>: "datetime", "object", "mm/dd/yyyy HH\:mm:ss", "dd.mm.yyyy h\:mm:ss a", "dd/mm/yyyy HH\:mm:ss z", "yyyymmddTh\:mm:ss a z", * "yyyy/mm/dd HH\:mm", "mmm dd, yyyy h\:mm a", "mmm d, yyyy HH", "mmm d, yyyy h a", * and other combinations of supported date and time formats.<br> * @returns {String | Date} The calculated date and time in the given format. * @example const date = common.date.calculateWithTime("today", "10:00"); * // returns a Date object like "Tue Jun 17 2025 08:17:27 GMT+0200 (Central European Summer Time)" * @example const date = common.date.calculateWithTime("today", "10:00:00", "mm/dd/yyyy HH:mm:ss"); * // returns a string like "06/17/2025 10:00:00" * @example const date = common.date.calculateWithTime("nextMonth", "9:00 PM", "mm-dd-yyyy h:mm a"); * // returns a string like "07-17-2025 9:00 PM" * @example const date = common.date.calculateWithTime("previousMonth", "22:00:45", "dd.mm.yyyy HH:mm:ss"); * // returns a string like "17.05.2025 22:00:45" * @example const date = common.date.calculateWithTime("nextYear", "3 AM", "dd/mm/yyyy h a"); * // returns a string like "17/06/2026 3 AM" * @example const date = common.date.calculateWithTime("previousYear", "15:30", "yyyymmddTHH:mm"); * // returns a string like "20240617T15:30" * @example const date = common.date.calculateWithTime("tomorrow", "10:00:50", "mmm dd, yyyy HH:mm:ss z"); * // returns a string like "Jun 18, 2025 10:00:50 GMT+02:00" * @example const date = common.date.calculateWithTime("today", "startOfDay", "dd.mm.yyyy HH:mm:ss"); * // returns a string like "17.06.2025 00:00:00" */ calculateWithTime(date?: CalculateDatesType, time?: Time, format?: DateTimeFormatsType): string | Date; private _calculateWithTimeFormatted; private _getCalculatedDate; } declare const _default: DateModule; export default _default;