1.8.3 Date and Time Data

Origin C provides support for date and time data.

Get Current Date Time

// Get current time
time_t aclock;
time( &aclock );

// Converts a time value and corrects for the local time zone
TM tmLocal;
convert_time_to_local(&aclock , &tmLocal);

// Convert time value from TM format to system time format
tm_to_systemtime(&tmLocal, &sysTime);	

// Get date string from system time
char 	lpcstrTime[100];
if(systemtime_to_date_str(&sysTime, lpcstrTime, LDF_SHORT_AND_HHMM_SEPARCOLON))
    printf("Current Date Time is %s\n", lpcstrTime);

Convert Julian Date to String

GetSystemTime(&st); // Gets current date time

double dJulianDate;
SystemTimeToJulianDate(&dJulianDate, &st); // Convert to Julian date

// Convert Julian date to string with the specified format
string strDate = get_date_str(dJulianDate, LDF_SHORT_AND_HHMM_SEPARCOLON);

Convert String to Julian Date

string strDate = "090425 17:59:59";
double dt = str_to_date(strDate, LDF_YYMMDD_AND_HHMMSS);