Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/datetime

Index

Variables

Const convertPhpDateTimeFormatToDateFns

convertPhpDateTimeFormatToDateFns: (...args: any[]) => any = memoize((format: string): string =>replaceAllInString(stripEscapedWords(format), PHP_TO_DATE_FNS_FORMAT_TOKEN_MAP))
description

Converts a date/time formatted with php and converts it to date-fns

param

The string to convert to date-fns format

returns

date-fns formatted date/time string

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Const convertPhpDateTimeFormatToMoment

convertPhpDateTimeFormatToMoment: (...args: any[]) => any = memoize((format: string): string =>replaceAllInString(stripEscapedWords(format), PHP_TO_MOMENT_FORMAT_TOKEN_MAP))
description

Converts a date/time formatted with php and converts it to moment

param

The string to convert to moment format

returns

moment formatted date/time string

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Functions

Const addDaysToTheGivenDate

  • addDaysToTheGivenDate(date: Date, days: number): Date
  • description

    Add the specified number of days to the given date.

    Parameters

    • date: Date

      Date to be updated.

    • days: number

      The amount of days to be added.

    Returns Date

    Updated date with the added days.

Const getDateFromUnixTime

  • getDateFromUnixTime(unixTime: number): Date
  • description

    Create a date from the given Unix timestamp (in seconds).

    Parameters

    • unixTime: number

      The given unix timestamp in seconds.

    Returns Date

    The date from the given unix timestamp.

Const getEndOfDay

  • getEndOfDay(date: Date): Date
  • description

    Return the end of a day for the given date. The result will be in the local timezone.

    Parameters

    • date: Date

      The date to find end of day of.

    Returns Date

    Date of end of day.

Const getEndOfMonth

  • getEndOfMonth(date: Date): Date
  • description

    Return the end of a month for the given date. The result will be in the local timezone.

    Parameters

    • date: Date

      The date to find end of month of.

    Returns Date

    Date of the end of month.

Const getUnixTime

  • getUnixTime(date: Date): number
  • description

    Get the unix timestamp in seconds for the given date.

    Parameters

    • date: Date

      The date whose unix timestamp in seconds is returned.

    Returns number

    Unix timestamp in seconds.

Const getZonedDateFromDateString

  • getZonedDateFromDateString(dateTimeString: string, timezone: string): Date
  • description

    Function to get a date object from a string and timezone

    Parameters

    • dateTimeString: string
    • timezone: string

    Returns Date

    Date

Const getZonedDateStringFromDateString

  • getZonedDateStringFromDateString(dateTimeString: string, timezone: string, dateFormat: string): string
  • description

    Function to get a date string for a given date string, timezone and format

    Parameters

    • dateTimeString: string
    • timezone: string
    • dateFormat: string

    Returns string

    string

Const is

  • is(date: Date): { after: any; before: any }
  • description

    Curried function that returns an object of functions that compare the first argument with argument provided to them.

    Parameters

    • date: Date

      The first given date.

    Returns { after: any; before: any }

    Object containing functions to compare the first date argument with.

    • after: function
      • after(secondGivenDate: Date): boolean
      • Parameters

        • secondGivenDate: Date

        Returns boolean

    • before: function
      • before(secondGivenDate: Date): boolean
      • Parameters

        • secondGivenDate: Date

        Returns boolean

Const isSameDay

  • isSameDay(firstDate: Date, secondDate: Date): boolean
  • description

    Returns true if the given dates are on the same day, month and year. Returns false otherwise.

    Parameters

    • firstDate: Date

      The first date to check.

    • secondDate: Date

      The second date to check.

    Returns boolean

    If the dates are the same.

Const setDayOfMonth

  • setDayOfMonth(date: Date, dayOfMonth: number): Date
  • description

    Set the day of the month to the given date.

    Parameters

    • date: Date

      Date to be updated.

    • dayOfMonth: number

      Day of the month for the new date.

    Returns Date

    Date updated with the new month.

Const startOfMonth

  • startOfMonth(date: Date): Date
  • description

    Return the start of a month for a given date.

    Parameters

    • date: Date

      Date to find start of month of.

    Returns Date

    Date of start of month.

Const subtractMonths

  • subtractMonths(date: Date, numberOfMonths: number): Date
  • description

    Subtract the specified number of months from the given date.

    Parameters

    • date: Date

      The date from of which the months are to be subtracted.

    • numberOfMonths: number

      The number of months to subtract from the given date.

    Returns Date

    The updated date with the subtracted months.

Generated using TypeDoc