Search
DateTime.fromDateParts Method
See Also
 






Creates a new DateTime object, by specifying its different date and time components.

Namespace: MindFusion.Scheduling
File: DateTime.js

 Syntax

JavaScript  Copy Code

function fromDateParts (year, month, [day, [hours, [minutes, [seconds, [milliseconds]]]]])

 Parameters

year

Number. The year component.

month

Number. The month component (0-11).

day
Optional.

Number. The day component (1-31). If not provided, a default value of 1 will be used.

hours
Optional.

Number. The hours component (0-23). If not provided, a default value of 0 will be used.

minutes
Optional.

Number. The minutes component (0-59). If not provided, a default value of 0 will be used.

seconds
Optional.

Number. The seconds component (0-59). If not provided, a default value of 0 will be used.

milliseconds
Optional.

Number. The milliseconds component (0-999). If not provided, a default value of 0 will be used.

 Return Value

The new DateTime object, or null if a DateTime instance cannot be created from the provided values.

 Example

The following code loads calendar data from a JSON array:

JavaScript  Copy Code

function loadCalendar(data)
{
 // clear existing items from the calendar schedule
 calendar.schedule.items.clear();

 // traverse the json object and create corresponding items in the calendar schedule
 for (var i=0; i<data.length; i++)
 {
  var date = p.DateTime.fromDateString(data[i].date);
  date = p.DateTime.fromDateParts(date.year, date.month, date.day, 0,0,0);
…………..
}

 See Also