API Docs for:
Show:

Formatter.util.date Class

Defined in: ../lib/pat.js:662
Module: pat

Date utility functions for the Gregorian calendar.

Item Index

Methods

Methods

century

(
  • date
)
Number static

Defined in ../lib/pat.js:898

Returns the century specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Number:

dayOfWeek

(
  • date
  • culture
)
Number static

Defined in ../lib/pat.js:741

Returns the culture-specific weekday of the given date. The first day of the week corresponds to 0, the last day to 6.

Parameters:

  • date Date

    Interpreted as a UTC value

  • culture Object

    Culture information

Returns:

Number:

dayOfYear

(
  • date
)
Number static

Defined in ../lib/pat.js:753

Returns the day of the year specified by the given date. The first day of the year corresponds to 1.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Number:

daysOfMonth

(
  • date
)
Number static

Defined in ../lib/pat.js:706

Returns the number of days for the specified month.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Number:

daysOfYear

(
  • arg
)
Number static

Defined in ../lib/pat.js:720

Returns the number of days for the specified year.

Parameters:

  • arg Date | Number

    (Date is interpreted as a UTC value)

Returns:

Number:

firstDayOfMonth

(
  • date
)
Date static

Defined in ../lib/pat.js:822

Returns a date representing the first day of the month specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Date:

firstDayOfWeek

(
  • date
  • culture
)
Date static

Defined in ../lib/pat.js:798

Returns a date representing the first day of the week specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

  • culture Object

    Culture information

Returns:

Date:

firstDayOfYear

(
  • arg
)
Date static

Defined in ../lib/pat.js:848

Returns a date representing the first day of the specified year.

Parameters:

  • arg Date | Number

    (Date is interpreted as a UTC value)

Returns:

Date:

isAM

(
  • date
)
Boolean static

Defined in ../lib/pat.js:918

Returns true if the time specified by the given date is in the range [00:00, 12:00). Returns false otherwise.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Boolean:

isLeapYear

(
  • arg
)
Boolean static

Defined in ../lib/pat.js:730

Returns true if the specified year is a leap year, false otherwise.

Parameters:

  • arg Date | Number

    (Date is interpreted as a UTC value)

Returns:

Boolean:

isoWeek

(
  • date
)
Number static

Defined in ../lib/pat.js:879

Returns the ISO-8601 week specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Number:

isPM

(
  • date
)
Boolean static

Defined in ../lib/pat.js:934

Returns true if the time specified by the given date is in the range [12:00, 00:00). Returns false otherwise.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Boolean:

lastDayOfMonth

(
  • date
)
Date static

Defined in ../lib/pat.js:833

Returns a date representing the last day of the month specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Date:

lastDayOfWeek

(
  • date
  • culture
)
Date static

Defined in ../lib/pat.js:810

Returns a date representing the first day of the week specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

  • culture Object

    Culture information

Returns:

Date:

lastDayOfYear

(
  • arg
)
Date static

Defined in ../lib/pat.js:862

Returns a date representing the last day of the specified year.

Parameters:

  • arg Date | Number

    (Date is interpreted as a UTC value)

Returns:

Date:

nthDayOfWeek

(
  • date
  • culture
  • n
)
Date static

Defined in ../lib/pat.js:772

Returns a date representing the n-th day of the week specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

  • culture Object

    Culture information

  • n Number

    In [0,6]

Returns:

Date:

Example:

    var d = new Date('2012-07-04T00:00Z'), //Wednesday
        c = { firstDayOfWeek: 1 }; //culture with Monday as first weekday

    Formatter.util.date.nthDayOfWeek(
        d, c, 0); //Date representing '2012-07-02T00:00'

    Formatter.util.date.nthDayOfWeek(
        d, c, 6); //Date representing '2012-07-08T00:00'

pastCenturies

(
  • date
)
Number static

Defined in ../lib/pat.js:908

Returns the number of past centuries specified by the given date.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Number:

timestamp

(
  • date
)
Number static

Defined in ../lib/pat.js:693

Returns the UNIX timestamp of the given date. The UNIX timestamp describes a UTC date as number of seconds elapsed since the beginning of the UNIX epoche (Midnight, 1970-01-01). Milliseconds of the given date are truncated.

Parameters:

  • date Date

    Interpreted as a UTC value

Returns:

Number:

Properties

MILLISECONDS_PER_DAY

Number final static

Defined in ../lib/pat.js:676

Milliseconds per day.

MILLISECONDS_PER_HOUR

Number final static

Defined in ../lib/pat.js:668

Milliseconds per hour.

MILLISECONDS_PER_WEEK

Number final static

Defined in ../lib/pat.js:684

Milliseconds per week.