The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 tm_yday not working in function systemtime_to_tm()
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

newuser_ca

70 Posts

Posted - 11/15/2011 :  3:52:23 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
when I convert systemtime to tm format, "tm_yday" shows "0".
The others (tm_sec, tm_min, etc) are ok.

My codes are:
/////////////////////////////////////
SYSTEMTIME systime;
TM t;
GetSystemTime(&systime);
systemtime_to_tm(&t, &systime);
////////////////////////////////////

Penn

China
644 Posts

Posted - 11/15/2011 :  10:23:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This is a bug. For now, you can set this value manually, for example:

// use Day function to get day of year, need to declare first
int Day(double date, int option = 1);  // option = 1 for month day, = 2 for year day


void testSYSTEMTIME_TM()
{
	SYSTEMTIME systime;
	TM t;
	GetSystemTime(&systime);
	systemtime_to_tm(&t, &systime);

	double lpdDate;
	SystemTimeToJulianDate(&lpdDate, &systime);  // get Julian date from SYSTEMTIME
	int nYDay = Day(lpdDate, 2);  // get day of year
	if(nYDay >= 0)
		t.tm_yday = nYDay;  // set tm_yday
}


Penn
Go to Top of Page

newuser_ca

70 Posts

Posted - 11/16/2011 :  09:24:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot.
It solves the problem.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000