/*

CLASS {NATIVE_Date_time|_Cpp}, NATIVE :


// {Date_time} native functions code:

CONST STR :
    NATIVE_Date_time_import = @
    "#ifdef MSWINDOWS"
    "	#include <time.h>"
    "#else"
    "	#include <sys/time.h>"
    "#endif"

    NATIVE_Date = @
    "   struct tm Tm;"
    "   memset(&Tm, 0, sizeof(Tm));"
	//"	Tm = {};"
    "   Tm.tm_year = X_Year - 1900;"
    "   Tm.tm_mon = X_Month - 1;"
    "   Tm.tm_mday = X_Day;"
    "   RESULT = mktime(&Tm) * 1000.0;"
    
    NATIVE_Now = @
    "#ifdef MSWINDOWS"
    "   SYSTEMTIME st;"
    "   GetLocalTime(&st);"
    "   struct tm Tm = {0};"
    "   Tm.tm_year = st.wYear - 1900;"
    "   Tm.tm_mon = st.wMonth - 1;"
    "   Tm.tm_mday = st.wDay;"
    "   Tm.tm_hour = st.wHour;"
    "   Tm.tm_min = st.wMinute;"
    "   Tm.tm_sec = st.wSecond;"
    "   RESULT = mktime(&Tm) * 1000.0 + st.wMilliseconds;"
    "#else"
    "	struct timeval te;"
    "	gettimeofday(&te, NULL);"
    "	RESULT = te.tv_sec * 1000.0 + te.tv_usec/1000;"
    "#endif"
    
    NATIVE_UTC_now = @
    "#ifdef MSWINDOWS"
    "   SYSTEMTIME st;"
    "   GetSystemTime(&st);"
    "   struct tm Tm = {0};"
    "   Tm.tm_year = st.wYear - 1900;"
    "   Tm.tm_mon = st.wMonth - 1;"
    "   Tm.tm_mday = st.wDay;"
    "   Tm.tm_hour = st.wHour;"
    "   Tm.tm_min = st.wMinute;"
    "   Tm.tm_sec = st.wSecond;"
    "   RESULT = mktime(&Tm) * 1000.0 + st.wMilliseconds;"
    "#else"
    "	struct timeval te;"
    "	gettimeofday(&te, NULL);"
    "	time_t ltime;"
    "	time(&ltime);"
    "	tm* newtime = gmtime(&ltime);"
    "	newtime->tm_hour = 0;"
    "	newtime->tm_min = 0;"
    "	newtime->tm_sec = 0;"
    "	time_t timex = mktime(newtime);"
    "	RESULT = (long long)timex * 1000.0 + te.tv_usec/1000;"
    "#endif"

    NATIVE_Year = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_year + 1900;"
    
    NATIVE_Month = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_mon + 1;"
     
    NATIVE_Day = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_mday;"
     
    NATIVE_Week_day = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_wday;"
     
    NATIVE_Hour = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_hour;"
     
    NATIVE_Minute = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_min;"
     
    NATIVE_Second = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_sec;"
     
    NATIVE_Millisecond = @
    "   RESULT = X_D - 1000.0 * (long)(X_D / 1000.0);"
     
    NATIVE_Day_of_year = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   RESULT = Tm->tm_yday + 1;"
     
    NATIVE_Days_in_month = @
    "   time_t t = (long int)(X_D / 1000);"
    "   struct tm * Tm = localtime(&t);"
    "   Tm->tm_mday = 1;"
    "   time_t From = mktime(Tm);"
    "   if (++Tm->tm_mon >= 12) {"
    "       Tm->tm_mon = 0;"
    "       ++Tm->tm_year;"
    "   }"
    "   time_t To = mktime(Tm);"
    "   RESULT = (int)((To - From) / 3600 / 24);"
    
    NATIVE_Date_time_Str = @
    "   time_t t = (long int)(X_D / 1000);"
    "   char buf[240];"
    "   struct tm * Tm = localtime(&t);"
    "   setlocale(LC_TIME, "#QU#QU" );"
    "   strftime(buf, sizeof(buf), "#QU"%x %X"#QU", Tm);"
    "   RESULT = buf;"
    .
         

END
*/

