Current date/time in format yyyymmddhhmmss

I am generating a report and need put the current date/time in the filename, but all DOORS canned formats that I know of contain slashes and/or colons, which are not allowed in filenames, e.g.:
 

stringOf(dateAndTime(today),loc,"yyyy-MM-dd")

 


Gives "2010-04-01 08:59:13", which is the information I need, but without the colons.

I don't actually care about separators; they could be any combination of none, spaces, hyphens, or underscores, as long as the information is (yy)yymmddhhmmss in that order.

I know this isn't rocket surgery, but I'm short on time and be grateful if someone has already written code to generate this format.

Many thanks,
Ken.

 


mcnairk - Thu Apr 01 09:12:23 EDT 2010

Re: Current date/time in format yyyymmddhhmmss
SystemAdmin - Thu Apr 01 10:28:49 EDT 2010

Time formtting in DXL appears to use the locale specifed format.

Here's some code to do what you want, irrespective of locale:

void printZeroPrefixedInt(int i)
{
string s = i ""
if (i < 10)
s = "0" s
print s
}
void printTime()
{
int now = intOf(dateAndTime(today))
Date d = dateOnly(today)
int day = intOf(date(stringOf(d)))
int diff = now-day
int hours = diff / 3600
int mins = (diff - (3600 * hours)) / 60
int secs = diff - (hours * 3600) - (mins * 60)

printZeroPrefixedInt hours
printZeroPrefixedInt mins
printZeroPrefixedInt secs
}

print stringOf(today, "yyyyMMdd")
printTime

Re: Current date/time in format yyyymmddhhmmss
mcnairk - Thu Apr 01 10:39:36 EDT 2010

SystemAdmin - Thu Apr 01 10:28:49 EDT 2010
Time formtting in DXL appears to use the locale specifed format.

Here's some code to do what you want, irrespective of locale:

void printZeroPrefixedInt(int i)
{
string s = i ""
if (i < 10)
s = "0" s
print s
}
void printTime()
{
int now = intOf(dateAndTime(today))
Date d = dateOnly(today)
int day = intOf(date(stringOf(d)))
int diff = now-day
int hours = diff / 3600
int mins = (diff - (3600 * hours)) / 60
int secs = diff - (hours * 3600) - (mins * 60)

printZeroPrefixedInt hours
printZeroPrefixedInt mins
printZeroPrefixedInt secs
}

print stringOf(today, "yyyyMMdd")
printTime

This is exactly what I want. Thanks a million!

Ken.