API Documentation

DateFromNDays

Computes the NxDate members from the NDays member.


    #define cszNxCoreDateFromNDays "sNxCoreDateFromNDays"
    typedef void (__stdcall *NxCoreDateFromNDays) (NxDate* pnxDate);

    void DateFromNDays(NxDate* pnxDate);

Parameters

pnxDate

The address of an NxDate structure with the NDays member field set.

Return Value

none

Comments

Use this function to convert NDays to an NxDate structure.

Example

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 WhatsInNDays(const NxDate& d, int n)
{
    NxDate t = d;

    t.NDays += n;

    nxCoreClass.DateFromNDays(&t);

    printf("Tape date is: %s %d/%.2d/%.2d -- in %d days it will be %s %d/%.2d/%.2d\n",
        days[d.DayOfWeek], (int) d.Year, (int) d.Month, (int) d.Day,
        n,
        days[t.DayOfWeek], (int) t.Year, (int) t.Month, (int) t.Day);

    return t.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;
                        WhatsInNDays(pNxCoreSys->nxDate, 5);
                    }

                    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;
}