Write the date as per the supplied format. The options are:- 1) As YYYYMMDD 2) As dayname, monthname day year (American) 3) As dayname, day monthname year (International) Pointer to buffer populated with the date in text form. Note: The space required is allocated from the thread scratch pad and must not be deleted by the calling function.
| Return Type | Function name | Arguments |
|---|---|---|
| const char* | hzSDate::Txt | (hzDateFmt,) |
Declared in file: hzDate.h
Defined in file : hzDate.cpp
Function Logic:
Function body:
const char* hzSDate::Txt (hzDateFmt eFmt)
{
// Write the date as per the supplied format. The options are:-
//
// 1) As YYYYMMDD
// 2) As dayname, monthname day year (American)
// 3) As dayname, day monthname year (International)
//
// Arguments: 1) eFmt Requested format of output string
//
// Returns: Pointer to buffer populated with the date in text form.
//
// Note: The space required is allocated from the thread scratch pad and must not be deleted by the calling function.
_hzfunc("hzSDate::Txt") ;
char* pBuf ; // Text recepticle
uint32_t Y ; // Year part
uint32_t M ; // Month part
uint32_t D ; // Day part
pBuf = _thisfn.ScratchPad(32);
if (m_days == NULL_DATE)
strcpy(pBuf, "Not set") ;
else
{
_datefromdays(Y, M, D, m_days) ;
switch (eFmt)
{
case FMT_DATE_DFLT: // yyyy/mm/dd
sprintf(pBuf, "%04d%02d%02d", Y, M, D) ;
break ;
case FMT_DATE_STD: // Dow, day month year
if (eFmt & FMT_DATE_USA)
sprintf(pBuf, "%s %s %d %04d", hz_daynames_abrv[Dow()], hz_monthnames_abrv[M - 1],D, Y) ;
else
sprintf(pBuf, "%s %d %s %04d", hz_daynames_abrv[Dow()], D, hz_monthnames_abrv[M - 1],Y) ;
break ;
default:
sprintf(pBuf, "Format unavailable") ;
break ;
}
}
return pBuf ;
}