Minimum Origin Version Required: Origin8 SR0
This section shows how to get system time, the conversion of Julian date with string, get Year, Month, Date... from Julian date and so on.
More details please reference to the following Origin C Reference section:
void GetSystemTimeEx() { SYSTEMTIME sysTime; GetSystemTime(&sysTime); char lpcstrTime[100]; if(systemtime_to_date_str(&sysTime, lpcstrTime)) printf("Today's date & time with your Origin custom date format = \"%s\"\n", lpcstrTime); char lpcstrTimeCustomizeFormat[100]; WORD wFormat = LDF_YYMMDD_AND_HHMMSS_SEPARCOLON; if(systemtime_to_date_str(&sysTime, lpcstrTimeCustomizeFormat, wFormat)) printf("Today's date & time with the specified date format = \"%s\"\n", lpcstrTimeCustomizeFormat); }
void get_date_string() { // get system time SYSTEMTIME st; GetSystemTime(&st); // convert to Julian Date double dDate; SystemTimeToJulianDate(&dDate, &st); // convert Julian Date to string string strDate = get_date_str(dDate, LDF_SHORT_AND_HHMM_SEPARCOLON); out_str(strDate); }
void str_to_date_ex1() { string strDate = "12/31/2009"; // Use your regional Short Date form double db = str_to_date(strDate, LDF_SHORT); if(!is_missing_value(db)) { printf("You have entered %s\n", get_date_str(db, LDF_LONG)); } else out_str("the string is not recorgnized as a date string"); }