Problem with dateTime format importing from XML

Hi

I have my event data stored in an XML database which I parse into the scheduler. All works with standard date format, eg. “2010-01-07 15:00”, but when I try to use the preferred format, eg. “2010-01-07T15:00:00” with the xml_date config set to “%Y-%m-%dT%H:%i:%s” the events don’t get imported.

Any thoughts?

Thanks

I have exactly the same problem json.net emits ISO 8601 formatted dates like this example {“data”:[{“id”:1,“text”:“Project #1”,“start_date”:“2013-04-01T00:00:00”,“duration”:20,“order”:0,“parent_id”:1},{“id”:2,“text”:“Task #1”,“start_date”:“2013-04-02T00:00:00”,“duration”:10,“order”:2,“parent_id”:1},{“id”:3,“text”:“Task #2”,“start_date”:“2013-04-23T00:00:00”,“duration”:5,“order”:3,“parent_id”:3},{“id”:4,“text”:“Task #3”,“start_date”:“2013-04-12T00:00:00”,“duration”:5,“order”:3,“parent_id”:3}],“links”:[{“id”:1,“source”:3,“target”:4,"_type":0}]}

The ‘T’ in the date can’t be parsed even if I put an explicit T in the xml_date format. gantt.config.xml_date = “%Y-%n-%dT%H:%i:%s”; Is the ‘T’ getting swallowed up by the parsing of the %d? I’ve verified it all works if I take out the ‘T’ on the server side and change the format string, but that’s a bit of a PITA, any advice appreciated

Darren

FWIW, using JSon.net, here’s an F# code fragment that reformats the dates to keep the gannt client happy

let so x = let dateConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter() dateConverter.DateTimeFormat <- "yyyy-MM-dd %HH:%mm:%ss" //Json.net emits Iso8601 format and dhtmlx can't handle it JsonConvert.SerializeObject (x,dateConverter)

In the javascript

gantt.config.xml_date = "%Y-%n-%d %H:%i:%s";

Hi Daz

I was looking at the regex crawler in dhtmlxscheduler.js (str_to_date) and, although I can’t quite get my head round it (I’m an integrator rather than a coder) I’ve managed to spoof it by using an xml_date of “%Y-%m-%d%T%H:%i:%s” so that the ‘T’ character doesn’t get included in the %d selector and then gets ignored. So loading works.

Looking at the reverse date_to_str I’ve got a feeling that an api_date of “%Y-%m-%dT%H:%i:%s” should work, but saving to the database is my next task :wink: