get_date_str

 

Description

convert a Julian date value into a string

Syntax

string get_date_str( double dDateTime, WORD wFormat = LDF_SHORT_AND_HHMMSS_SEPARCOLON, LPCSTR lpcszCustom = NULL )

Parameters

dDateTime
[input] A Julian date time value, where the integral part represent the Julian Days while the fractional part as fraction of a Day
wFormat
[input] must be the enumeration LDF_SHORT, LDF_LONG, LDF_ALPHAMONTH_NUMERICDAY, etc
lpcszCustom
[input] custom format. if nFmt is LDF_OBJ_CUSTOM, then use this param as the custom date format.

Return

A string containing the converted date/time.

Examples

EX1

void    get_date_str_ex1()
{
    SYSTEMTIME st;
    GetSystemTime(&st);              // gets current time, 
    // need to convert to local time
    FILETIME ft, ftLocal;
    SystemTimeToFileTime(&st, &ft);
    FileTimeToLocalFileTime(&ft, &ftLocal);
    FileTimeToSystemTime(&ftLocal, &st);
    double dDate;
    SystemTimeToJulianDate(&dDate, &st);
    out_str(get_date_str(dDate, LDF_SHORT_AND_HHMM_SEPARCOLON));
}

EX2

void    get_date_str_ex2()
{
    SYSTEMTIME st;
    GetSystemTime(&st); // gets current time, 
    // need to convert to local time
    FILETIME ft, ftLocal;
    SystemTimeToFileTime(&st, &ft);
    FileTimeToLocalFileTime(&ft, &ftLocal);
    FileTimeToSystemTime(&ftLocal, &st);
    double dDate;
    SystemTimeToJulianDate(&dDate, &st);
    
    out_str(get_date_str(dDate, LDF_OBJ_CUSTOM, "yyyy/MM/dd"));
}

Remark

See Also

str_to_date

Header to Include

origin.h

Reference