Moscrif API Docs for: 2012q3
Show:

Date Class

Library: core

Represents date and time. Local and UTC timezones supported.

Example:

var d = new Date();
console.printf("today is: %d-%d-%d %d:%d:%d\n", d.day, d.month, d.year, d.hour, d.minute, d.second);
// UTC
d = new Date("28 Feb 1980 UTC");
if (d.UTCday != 28 || f.UTCmonth != 2 || d.UTCyear != 1980) throw "date ctor";
// Locale strings
console <<<< d.toLocaleString(true, 1);

Methods

this

(
  • [value]
)
Date

Constructor - creates new date object. If no parameters were given then initializes date fields to the current time (UTC). If single string parameter provided then parses date contained in the string.

Parameters:

Returns:

Date: New instance of Date class.

Example:

var d = new Date();

this

(
  • [year]
  • [month]
  • [day]
  • [hour]
  • [minute]
  • [second]
  • [millisecond]
)
Date

Constructor - creates new date object. If no parameters were given then initializes date fields to the current time (UTC). If single string parameter provided then parses date contained in the string.

Parameters:

  • [year] Integer optional

    full number of the year, e.g. 2005.

  • [month] Integer optional

    number of the month, from 1 to 12.

  • [day] Integer optional

    number of the day, from 1 up to number of days in the month.

  • [hour] Integer optional

    hour, from 0 to 23.

  • [minute] Integer optional

    minute, from 0 to 59.

  • [second] Integer optional

    second, from 0 to 59.

  • [millisecond] Integer optional

    millisecond, from 0 to 999.

Returns:

Date: New instance of Date class.

dayOfWeekName

(
  • longFormat
)
String

Find out name of the day in current user's locale.

Parameters:

  • longFormat Boolean

    If longFormat is equal true returns full week name, otherwise - it's abbreviation.

Returns:

String: String of day's name

isDaylight

() Boolean

Find out if current clock is using daylight saving time.

Returns:

Boolean: True if current clock is using daylight saving time.

monthName

(
  • longFormat
)
String

Find out name of the month in current user's locale.

Parameters:

  • longFormat Boolean

    If longFormat is equal true returns full month name, otherwise - it's abbreviation.

Returns:

String: String of month's name

now

(
  • [sequential=false]
)
Date

Actual date

Parameters:

  • [sequential=false] Boolean optional

    This ensures that two consequtive calls of Date.now(true) return distinct values.

Returns:

Date: New instance of date class.

parse

(
  • value
)
Date

This function parse date in string

Parameters:

Returns:

Date: If result of parsing is successfull then returns Date as number of milliseconds since midnight, January 1, 1970 UTC. On error returns undefiend value.

setTime

(
  • milliseconds
)

Sets this date object fields equal to date defined by milliseconds parameter.

Parameters:

  • milliseconds Integer

    number of milliseconds since midnight, January 1, 1970 UTC.

tick

() Integer

Number of miliseconds. This property is suitable for animation (game) scheduling.

Returns:

Integer: Number off milliseconds.

timeZoneName

() String

Returns name of current timezone.

Returns:

String: Name of current timezone.

timeZoneOffset

() Integer

Returns shift in milliseconds of current timezone from GMT.

Returns:

Integer: Shift in milliseconds of current timezone from GMT.

toISOString

(
  • [asUTC=false]
)
String

Creates ISO 8601 string representation of this date object as either local or UTC date/time.

Parameters:

  • [asUTC=false] Boolean optional

    True for UTC time, false for local time. The default je false.

Returns:

String: ISO 8601 string representation of this date object as either local or UTC date/time.

toLocaleString

(
  • longFormat
  • longFormat
)
String

Returns string representation of the date using current system settings.

Parameters:

  • longFormat Boolean

    If longFormat is equal exactly true then formats date using system long date format.

  • longFormat Integer

    This parameter defines formatting style. Argument typeFormat can by one of: * 0 - result strings will containts both date and time part * 1 - string will represent only date part * 2 - only time part will be displayed in result string representation.

Returns:

toString

() String

Creates RFC-822 string representation of this date object.

Returns:

String: RFC-822 string representation of this date object

toUTCString

() String

Creates RFC-822 string representation of this date object as UTC date/time.

Returns:

String: Returns RFC-822 string representation of this date object as UTC date/time.

UTC

(
  • [year]
  • [month]
  • [day]
  • [hour]
  • [minute]
  • [second]
  • [millisecond]
)
Integer

Calculate number of milliseconds since midnight, January 1, 1970 UTC up to date defined by parameters

Parameters:

  • [year] Integer optional

    full number of the year, e.g. 2005.

  • [month] Integer optional

    number of the month, from 1 to 12.

  • [day] Integer optional

    number of the day, from 1 up to number of days in the month.

  • [hour] Integer optional

    hour, from 0 to 23.

  • [minute] Integer optional

    minute, from 0 to 59.

  • [second] Integer optional

    second, from 0 to 59.

  • [millisecond] Integer optional

    millisecond, from 0 to 999.

Returns:

Integer: Number of milliseconds since midnight, January 1, 1970 UTC up to date defined by parameters.

valueOf

() Float

Calculate number o milliseconds since midnight, January 1, 1970 UTC.

Returns:

Float: Stored time value in milliseconds since midnight, January 1, 1970 UTC.

Properties

day

Integer

Number of the day, from 1 up to number of days in current month.

dayOfWeek

Integer

Day of the week, number of day of the week, from 0 to 6 where 0 is Monday.

firstDayOfWeek

Integer

First day of the week in current locale, from 0 to 6 where 0 is Monday.

hour

Integer

Hour, from 0 to 23.

millisecond

Integer

Millisecond, from 0 to 999.

minute

Integer

Minute, from 0 to 59.

month

Integer

Number of the month, from 1 to 12.

second

Integer

Second, from 0 to 59.

UTCday

Integer

UTCday, number of the day, from 1 up to number of days in current month.

UTCdayOfWeek

Integer

UTCdayOfWeek, number of day of the week, from 0 to 6 where 0 is Monday.

UTChour

Integer

UTChour, from 0 to 23.

UTCmillisecond

Integer

UTCmillisecond, from 0 to 999.

UTCminute

Integer

UTCminute, from 0 to 59.

UTCmonth

Integer

UTCmonth, Number of the month, from 1 to 12.

UTCsecond

Integer

UTCsecond, from 0 to 59.

UTCyear

Integer

UTCyear, full number of the year, e.g. 2005.

year

Integer

Full number of the year, e.g. 2012.