CSPTime

Published
m_tmEnd		=	CSPTime(tmCurrent.GetYear(),tmCurrent.GetMonth(),tmCurrent.GetDay(),23,59,59,0);
DWORD	secNow = CSPTime::GetCurrentTime().ToStockTimeSecOrder();//获取当前时间
WORD	dwSeconds = CSPTime::GetTradeSecondsOfOneDay();
DWORD secTemp = CSPTime(aMinute[ptr].m_time).ToStockTimeSecOrder();

 

m_tmBegin	=	m_tmBegin - CSPTimeSpan( 365 * 3, 0, 0, 0 );

strTemp = sptime.Format("%y-%m-%d(%w)");

实际上是用的

wcsftime

使用格式见:

https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?view=vs-2019

根据时间取周一到周日

StkLib\Src\AfxCore.cpp

//////////////////////////////////////////////////////////////////////////////////
// usful functions
CSPString AfxGetTimeString( time_t time, LPCTSTR lpszTimeFmt, BOOL bAddWeekDay )
{
	SP_ASSERT( lpszTimeFmt );
	if( !lpszTimeFmt || strlen(lpszTimeFmt) == 0 )
		return "";

	CSPTime	sptime(time);
	CSPString strTime = sptime.Format( lpszTimeFmt );

	if( bAddWeekDay )
	{
		int	nDayOfWeek	=	sptime.GetDayOfWeek();
		switch( nDayOfWeek )
		{
		case 1:	strTime	+=	sz_sunday;		break;
		case 2:	strTime	+=	sz_monday;		break;
		case 3:	strTime	+=	sz_tuesday;		break;
		case 4:	strTime	+=	sz_wednesday;	break;
		case 5:	strTime	+=	sz_thursday;	break;
		case 6:	strTime	+=	sz_friday;		break;
		case 7:	strTime	+=	sz_saturday;	break;
		default:;
		}
	}
	return strTime;
}

 

CSPTime CStDatabase::GetTimeInitial( )
{
	return CSPTime( 1990, 12, 19, 0, 0, 0 );
}

 

时间转换函数-分笔数据时间秒数转换为日期

kd.m_date	=	CSPTime(pReport->m_time).ToStockTimeDay();
//kd.m_date=20201105
if (!CSPTime::InTradeTime(ElementAt(i).m_time, 60))
			RemoveAt(i);
DWORD	dwDate = CSPTime::GetCurrentTime().ToStockTimeDay();

 

将成交明细转换为1分钟线

CSPTime	t(report.m_time);
		time_t	day = (t.GetTime() + 8 * 3600) % 86400;
		int nInflateSeconds = 60;

		//加5分钟,9:25那一笔变为 9:30
		if (day >= 9 * 3600 + 25 * 60 - nInflateSeconds && day <= 9 * 3600 + 29 * 60 + nInflateSeconds)
		{
			report.m_time += 5 * 60;

		}

		CSPTime sptime(report.m_time);
		kd.m_date = sptime.ToStockTimeMin()+1; //从9:30 变为 9:31