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 |
|
|
|
|
new Date (value) Internal Properties |
|
|
|
|
new Date ( ) Internal Properties |
|
|
|
|
Properties of the Date Constructor |
|
|
Functions of the Date Constructor |
|
|
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 |
|
Constructor of Date
Prototype
The initial value of Date.prototype.constructor
is the built-in Date
constructor.
Methods of the Date Prototype |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 }.