comparison core.js @ 1631:91a75ec7a7c0

Feature #1245: Added DateTime node to XML output
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 27 May 2015 09:46:06 +0100
parents 21381e163787
children ba734075da2d
comparison
equal deleted inserted replaced
1630:a164ca5c2ec3 1631:91a75ec7a7c0
588 // Pick out that element and delete from the array 588 // Pick out that element and delete from the array
589 holdArr.push(input.splice(r,1)[0]); 589 holdArr.push(input.splice(r,1)[0]);
590 } 590 }
591 return holdArr; 591 return holdArr;
592 } 592 }
593
594 function returnDateNode()
595 {
596 // Create an XML Node for the Date and Time a test was conducted
597 // Structure is
598 // <datetime>
599 // <date year="##" month="##" day="##">DD/MM/YY</date>
600 // <time hour="##" minute="##" sec="##">HH:MM:SS</time>
601 // </datetime>
602 var dateTime = new Date();
603 var year = document.createAttribute('year');
604 var month = document.createAttribute('month');
605 var day = document.createAttribute('day');
606 var hour = document.createAttribute('hour');
607 var minute = document.createAttribute('minute');
608 var secs = document.createAttribute('secs');
609
610 year.nodeValue = dateTime.getFullYear();
611 month.nodeValue = dateTime.getMonth()+1;
612 day.nodeValue = dateTime.getDate();
613 hour.nodeValue = dateTime.getHours();
614 minute.nodeValue = dateTime.getMinutes();
615 secs.nodeValue = dateTime.getSeconds();
616
617 var hold = document.createElement("datetime");
618 var date = document.createElement("date");
619 date.textContent = year.nodeValue+'/'+month.nodeValue+'/'+day.nodeValue;
620 var time = document.createElement("time");
621 time.textContent = hour.nodeValue+':'+minute.nodeValue+':'+secs.nodeValue;
622
623 date.setAttributeNode(year);
624 date.setAttributeNode(month);
625 date.setAttributeNode(day);
626 time.setAttributeNode(hour);
627 time.setAttributeNode(minute);
628 time.setAttributeNode(secs);
629
630 hold.appendChild(date);
631 hold.appendChild(time);
632 return hold
633
634 }