Computes the NxDate members from the Year, Month, Day members.
#define cszNxCoreDateFromYMD "sNxCoreDateFromYMD"
typedef void (__stdcall *NxCoreDateFromYMD) (NxDate* pnxDate);
void DateFromYMD(
NxDate* pnxDate
);
Parameters
pnxDate
The Address of an NxDate structure with the Year, Month, and Day fields set.
Return Value
none
Comments
Use this function to convert a year, month, and day, to an NxDate structure.
Here's an example of some date functions
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>
#include <NxCoreAPI.h>
#include <NxCoreAPI_class.h>
NxCoreClass nxCoreClass;
const char* days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
int HowLongUntilNewYears(const NxDate& d)
{
NxDate nxDateToday = d;
nxCoreClass.DateFromYMD(&nxDateToday);
NxDate nxDateNewYears;
nxDateNewYears.Year = d.Year + 1;
nxDateNewYears.Month = 1;
nxDateNewYears.Day = 1;
nxCoreClass.DateFromYMD(&nxDateNewYears);
int nDays = nxDateNewYears.NDays - nxDateToday.NDays;
printf("Tape date is: %s %d/%.2d/%.2d (%d day of the year) -- it's %d days until New Year\n",
days[d.DayOfWeek], (int) d.Year, (int) d.Month, (int) d.Day, (int) d.DayOfYear, nDays);
return nDays;
}
int HowLongUntilFriday(const NxDate& d)
{
NxDate nxDateToday = d;
nxCoreClass.DateFromYMD(&nxDateToday);
int nDays = NxDOW_FRIDAY - (nxDateToday.NDays % 7);
if (nDays == 0)
{
printf("Tape date is: %s %d/%.2d/%.2d -- it's FRIDAY!\n",
days[d.DayOfWeek], (int) d.Year, (int) d.Month, (int) d.Day);
return nDays;
}
if (nDays < 0)
{
nDays += 7; // must be saturday
}
printf("Tape date is: %s %d/%.2d/%.2d -- %d days until Friday!\n",
days[d.DayOfWeek], (int) d.Year, (int) d.Month, (int) d.Day, nDays);
return nDays;
}
int __stdcall nxCoreCallback(const NxCoreSystem* pNxCoreSys, const NxCoreMessage* pNxCoreMessage)
{
switch (pNxCoreMessage->MessageType)
{
case NxMSG_STATUS:
{
switch (pNxCoreSys->Status)
{
case NxCORESTATUS_RUNNING:
{
static bool needToPrint = true;
if (needToPrint && pNxCoreSys->nxTime.MsOfDay > 0)
{
needToPrint = false;
HowLongUntilNewYears(pNxCoreSys->nxDate);
HowLongUntilFriday(pNxCoreSys->nxDate);
}
break;
}
}
}
}
return NxCALLBACKRETURN_CONTINUE;
}
int main(int argc, char** argv)
{
if (!nxCoreClass.LoadNxCore("NxCoreAPI.dll") &&
!nxCoreClass.LoadNxCore("C:\\Program Files\\Nanex\\NxCoreAPI\\NxCoreAPI.dll"))
{
fprintf(stderr, "Can't find NxCoreAPI.dll\n");
return -1;
}
nxCoreClass.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback);
return 0;
}