Date- and Time-related Functions

Desigo CC scripting capability supports the following date- and time-related functions.

Date Objects

Date objects are part of the standard built-in ECMAScript objects.

For more details, see http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.

List of Date Objects

  • Time Values and Time Range
  • Day Number and Time within Day
  • Year Number
  • Month Number
  • Date Number
  • Week Day
  • Local Time Zone Adjustment
  • Daylight Saving Time Adjustment
  • Local Time
  • Hours, Minutes, Second, and Milliseconds

List of Abstract Operators

  • MakeTime (hour, min, sec, ms)
  • MakeDay (year, month, date)
  • MakeDate (day, time)
  • TimeClip (time)

Date Time String Format

ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 Extended Format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ.

For extended years, ISO 8601 permits the expansion of the year representation, but only by prior agreement between the sender and the receiver. In the simplified ECMAScript format such an expanded year representation shall have 2 extra year digits and is always prefixed with a + or – sign. The year 0 is considered positive and hence prefixed with a + sign.

Date Constructor Called as a Function

When Date is called as a function rather than as a constructor, it returns a String representing the current time (UTC).

NOTE: The function call Date(…) is not equivalent to the object creation expression new Date(…) with the same arguments.

 

Date ( [ year [, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] ] ] )

 

All of the arguments are optional; any arguments supplied are accepted but are completely ignored. A String is created and returned as if by the expression (new Date()).toString() where Date is the standard built-in constructor with that name and toString is the standard built-in method Date.prototype.toString.

Date Constructor

When Date is called as part of a new expression, it is a constructor: it initializes the newly created object.

 

new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )

 

When Date is called with two to seven arguments, it computes the date from year, month, and (optionally) date, hours, minutes, seconds and milliseconds (ms).

 

Date Constructor Internal Properties

[[Prototype]]

[[Class]]

[[Extensible]]

[[PrimitiveValue]]

new Date (value) Internal Properties

[[Prototype]]

[[Class]]

[[Extensible]]

[[PrimitiveValue]]

new Date ( ) Internal Properties

[[Prototype]]

[[Class]]

[[Extensible]]

[[PrimitiveValue]]

Properties of the Date Constructor

length

Date.prototype

Functions of the Date Constructor

Date.parse (string)

Date.UTC (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )

Date Prototype Object

The Date prototype object is itself a Date object (its [[Class]] is "Date") whose [[PrimitiveValue]] is NaN.

 

Internal Properties of the Date Prototype

[[Prototype]]

Constructor of Date Prototype

The initial value of Date.prototype.constructor is the built-in Date constructor.

 

Methods of the Date Prototype

Date.prototype.toString ( )

Date.prototype.toDateString ( )

Date.prototype.toTimeString ( )

Date.prototype.toLocaleString ( )

Date.prototype.toLocaleDateString ( )

Date.prototype.toLocaleTimeString ( )

Date.prototype.valueOf ( )

Date.prototype.getTime ( )

Date.prototype.getFullYear ( )

Date.prototype.getUTCFullYear ( )

Date.prototype.getMonth ( )

Date.prototype.getUTCMonth ( )

Date.prototype.getDate ( )

Date.prototype.getUTCDate ( )

Date.prototype.getDay ( )

Date.prototype.getUTCDay ( )

Date.prototype.getHours ( )

Date.prototype.getUTCHours ( )

Date.prototype.getMinutes ( )

Date.prototype.getUTCMinutes ( )

Date.prototype.getSeconds ( )

Date.prototype.getUTCSeconds ( )

Date.prototype.getMilliseconds ( )

Date.prototype.getUTCMilliseconds ( )

Date.prototype.getTimezoneOffset ( )

Date.prototype.setTime (time)

Date.prototype.setMilliseconds (ms)

Date.prototype.setUTCMilliseconds (ms)

Date.prototype.setSeconds (sec [, ms ] )

Date.prototype.setUTCSeconds (sec [, ms ] )

Date.prototype.setMinutes (min [, sec [, ms ] ] )

Date.prototype.setUTCMinutes (min [, sec [, ms ] ] )

Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] )

Date.prototype.setUTCHours (hour [, min [, sec [, ms ] ] ] )

Date.prototype.setDate (date)

Date.prototype.setUTCDate (date)

Date.prototype.setMonth (month [, date ] )

Date.prototype.setUTCMonth (month [, date ] )

Date.prototype.setFullYear (year [, month [, date ] ] )

Date.prototype.setUTCFullYear (year [, month [, date ] ] )

Date.prototype.toUTCString ( )

Date.prototype.toISOString ( )

Date.prototype.toJSON ( key )

See also Additional Methods of Date Prototype, below.

Properties of Date Instances

Date instances inherit properties from the Date Prototype object and their [[Class]] internal property value is "Date". Date instances also have a [[PrimitiveValue]] internal property.

The [[PrimitiveValue]] internal property is time value represented by this Date object.

Additional Methods of Date Prototype

In addition to the methods of the ECMAScript Date Prototype object, the Scripts feature also supports the following methods.

Date.quarter

The Date.quarter function allows calculating quarter of the year from a date.

Syntax

<Date object>.quarter();

Example of use

new Date("Feb 29, 2016").quarter()

The method returns 1.

Date.quarterUTC

The Date.quarterUTC function allows calculating quarter of the year from a date converted to UTC format.

Syntax

<Date object>.quarterUTC();

Example of use

new Date("Feb 29, 2016").quarterUTC()

The method returns 1.

Date.timeDiff

The Date.timeDiff allows calculating the time difference (in day, hours, minutes, seconds, milliseconds) between two dates/times. The result is an object that contains the time difference (hours, minutes, seconds, and milliseconds).

Syntax

<Date object>.timeDiff(date1,date2)

Example of use

var dateA = new Date(2014, 10, 24, 23, 18, 41, 718);

var dateB = new Date(2014, 10, 24, 22, 13, 41);

var myTimeDiff = Date.timeDiff(dateB, dateA);

The method returns an object { day:0, hours:1, minutes:5, seconds:0, milliseconds:718 }.