UNPKG

@luke-zhang-04/dateplus

Version:

A simple program to assist with date manipulation

87 lines (86 loc) 2.75 kB
/** * DatePlus A simple program to assist with date manipulation * * @license MIT * @version 4.0.0-beta2 * @author Luke Zhang luke-zhang-04.github.io * @copyright Copyright (C) 2020 - 2021 Luke Zhang */ import * as utils from "./utils"; /** * Dateplus - A class and namespace program to assist with date manipulation */ export declare class DatePlus extends Date { /** * Add's 0s to date (e.g 2020/4/3 => 2020/04/03) * * @param date - String date to format * @param seperator - Char the date is seperatred by * @returns - Date with zeros */ addZeros(seperator?: string): string; /** * Format instantiated into a string in the form YYYY{seperator}MM{seperator}DD * * @param seperator - Char to seperate date with * @param format - Format of string date * @returns Formatted date */ formatDate(format?: utils.DateFormat, seperator?: string): string; /** * Gets instantiated day of week in word form (e.g 0 => "Sunday") * * @returns Stringed day of week */ getWordDay(): string; /** * Gets instantiated month in word form (e.g 0 => "January") * * @returns Stringed worded month */ getWordMonth(): string; /** * Calculates number of elapsed days between instantiated date and dae * * @param date - Ending date object to calculate * @returns - Number of elapsed days */ getElapsedDays(date: Date): number; /** * Calculates number of elapsed hours between date1 and date2 * * @param date - Ending date object to calculate * @returns - Number of elapsed hours */ getElapsedHours(date: Date): number; /** * Calculates number of elapsed minutes between date1 and date2 * * @param date - Ending date object to calculate * @returns - Number of elapsed minutes */ getElapsedMinutes(date: Date): number; /** * Calculates number of elapsed seconds between date1 and date2 * * @param date - Ending date object to calculate * @returns - Number of elapsed seconds */ getElapsedSeconds(date: Date): number; /** * Calculates number of elapsed milliseconds between date1 and date2 * * @param date - Ending date object to calculate * @returns - Number of elapsed milliseconds */ getElapsedMs(date: Date): number; /** * Calculates elapsed time between current and previous * * @param date - End date * @param approx - Text to append to values from days and on, e.g *about* 1 day aga * @returns Time difference in string form, e.g "3 seconds ago" */ getElapsedString(date: Date, approx?: string): string; } export default DatePlus;