main.date

dojo/main.date

Properties

stamp

Defined by: dojo/date/stamp

TODOC

Methods

add(date,interval,amount)

Defined by dojo/date

Add to a Date in intervals of different size, from milliseconds to years

Parameter Type Description
date Date

Date object to start with

interval String

A string representing the interval. One of the following: "year", "month", "day", "hour", "minute", "second", "millisecond", "quarter", "week", "weekday"

amount int

How much to add to the date.

Returns: instance

compare(date1,date2,portion)

Defined by dojo/date

Compare two date objects by date, time, or both.

Returns 0 if equal, positive if a > b, else negative.

Parameter Type Description
date1 Date

Date object

date2 Date
Optional

Date object. If not specified, the current Date is used.

portion String
Optional

A string indicating the "date" or "time" portion of a Date object. Compares both "date" and "time" by default. One of the following: "date", "time", "datetime"

Returns: number

difference(date1,date2,interval)

Defined by dojo/date

Get the difference in a specific unit of time (e.g., number of months, weeks, days, etc.) between two dates, rounded to the nearest integer.

Parameter Type Description
date1 Date

Date object

date2 Date
Optional

Date object. If not specified, the current Date is used.

interval String
Optional

A string representing the interval. One of the following: "year", "month", "day", "hour", "minute", "second", "millisecond", "quarter", "week", "weekday"

Defaults to "day".

Returns: undefined

getDaysInMonth(dateObject)

Defined by dojo/date

Returns the number of days in the month used by dateObject

Parameter Type Description
dateObject Date

Returns: number | undefined

getTimezoneName(dateObject)

Defined by dojo/date

Get the user's time zone as provided by the browser

Try to get time zone info from toString or toLocaleString method of the Date object -- UTC offset is not a time zone. See http://www.twinsun.com/tz/tz-link.htm Note: results may be inconsistent across browsers.

Parameter Type Description
dateObject Date

Needed because the timezone may vary with time (daylight savings)

Returns: undefined

isLeapYear(dateObject)

Defined by dojo/date

Determines if the year of the dateObject is a leap year

Leap years are years with an additional day YYYY-02-29, where the year number is a multiple of four with the following exception: If a year is a multiple of 100, then it is only a leap year if it is also a multiple of 400. For example, 1900 was not a leap year, but 2000 is one.

Parameter Type Description
dateObject Date

Returns: boolean

© 2005–2015 The Dojo Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/main.date.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部