Although DOORS prints dates correctly, there is no easy way to create a date string in a specified format within DXL. These utilities return date strings in long format DD Month YYYY and DD Month YYYY HH:MM respectively.
Usage:
string getDateString(Date d) string getDateAndTimeString(Date d)
Example:
Date d = dateOf(intOf(today)) print d "\n" print getDateString(d) "\n" print getDateAndTimeString(d) "\n"
These functions are defined as follows:
// Date Handling Utilities /* Date Handling Utilities to return date strings in long format, optionally with time. smartDXL.com */ const string monthStrs[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } const string monthStrings[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } Regexp hasDate = regexp "(([0-9]*)/([0-9]*)/([0-9]*))" Regexp hasTime = regexp "(([0-9]*):([0-9]*):([0-9]*))" /****************************************************** getDateAndTimeString if incTime = TRUE, returns date and time in long format DD Month YYYY HH:MM if incTime = FALSE, returns date in long format DD Month YYYY ******************************************************/ string getDateAndTimeString(Date d, bool incTime) { string dateAndTime = null string sTime = null int iDay = 0 int iMonth = 0 int iYear = 0 dateAndTime = (dateOf(intOf(d))) "" if (hasDate dateAndTime) { iDay = intOf(dateAndTime[match 3]) iMonth = intOf(dateAndTime[match 2]) iYear = intOf(dateAndTime[match 4]) iYear += (iYear >= 50 ? 1900 : 2000) } else { return("") } if (hasTime dateAndTime) { sTime = dateAndTime[match 2] ":" dateAndTime[match 3] } return(iDay " " monthStrings[iMonth - 1] " " iYear (incTime ? " " sTime : "")) } /****************************************************** getDateAndTimeString Returns date in long format DD Month YYYY HH:MM ******************************************************/ string getDateAndTimeString(Date d) { return(getDateAndTimeString(d, true)) } /****************************************************** getDateString Returns date in long format DD Month YYYY ******************************************************/ string getDateString(Date d) { return(getDateAndTimeString(d, false)) }