xml_date

a string from an XML file is converted into a date object in conformity with this template

Parameters

dateDatethe date which needs formatting

Example

gantt.templates.xml_date = function(date){
    return gantt.date.date_to_str(gantt.config.xml_date)(date);
};

Details

The template is deprecated. Use parse_date instead:

var cfg = gantt.config;
var strToDate = gantt.date.str_to_date(cfg.date_format, cfg.server_utc);
 
gantt.templates.parse_date = function(date){
    return strToDate (date);
};

This template is automatically generated from the xml_date config and can be redefined after the initialization of gantt.

A custom template function can be used, if the format of server dates is not supported by the gantt date helper.

For example, using UNIX time for start_date:

/data

{
    "data":[
    {
        "id":1,
        "start_date":1503608400,
        "duration":10,
        "text":"Task #1",
        "parent":0,
    },
    {
        "id":2,
        "start_date":1503694800,
        "duration":4,
        "text":"Task #2",
        "parent":0,
    }],
 
    "links":[
    ]
}

You should set the Gantt configuration as follows:

gantt.attachEvent("onTemplatesReady", function(){
    gantt.templates.xml_date = function(dateString){
        return new Date(dateString * 1000);
    }
});
 
gantt.init("gantt_here");
gantt.load("/data");
See also
Change log

deprecated since v6.2

Back to top