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.
Here's an example of some date functions
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include "NxCoreAPI.h" #include "NxCoreAPI_Wrapper_C++.h" NxCoreClass NxCore; const char* days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; int WhatsInNDays(const NxDate& d, int n) { NxDate t = d; t.NDays += n; NxCore.DateFromNDays(&t); printf("Tape date is: %s %d/%02d/%02d -- in %d days it will be %s %d/%02d/%02d\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) { if (pNxCoreMessage->MessageType == NxMSG_STATUS && pNxCoreSys->Status == NxCORESTATUS_RUNNING && pNxCoreSys->nxTime.MsOfDay > 0) { WhatsInNDays(pNxCoreSys->nxDate, 5); return NxCALLBACKRETURN_STOP; } return NxCALLBACKRETURN_CONTINUE; } int main(int argc, char** argv) { if (!NxCore.LoadNxCore("NxCoreAPI64.dll") && !NxCore.LoadNxCore("NxCoreAPI.dll")) { printf("loading library failed\n"); return -1; } NxCore.ProcessTape(argv[1], 0, NxCF_EXCLUDE_CRC_CHECK, 0, nxCoreCallback); return 0; } |
import net.nanex.NxCoreClass; class DateFromNDaysSample extends NxCoreClass{ String days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; int WhatsInNDays(NxDate d, int n) { NxDate t = new NxDate(); t.NDays = d.NDays + n; DateFromNDays(t); System.out.println(String.format("Tape date is: %s %d/%02d/%02d -- in %d days it will be %s %d/%02d/%02d", days[d.DayOfWeek], d.Year, d.Month, d.Day, n, days[t.DayOfWeek], t.Year, t.Month, t.Day)); return t.NDays; } // The callback @Override public int OnNxCoreCallback(NxCoreSystem nxCoreSys, NxCoreMessage nxCoreMsg) { if( nxCoreMsg.MessageType == defines.NxMSG_STATUS && nxCoreSys.Status == defines.NxCORESTATUS_RUNNING && nxCoreSys.nxTime.MsOfDay != 0 ) { WhatsInNDays(nxCoreSys.nxDate); return defines.NxCALLBACKRETURN_STOP; } return defines.NxCALLBACKRETURN_CONTINUE; } public static void main(String args[]) { DateFromNDaysSample nxCore = new DateFromNDaysSample(); if (nxCore.LoadNxCore("NxCoreAPI64.dll") != 0){ nxCore.ProcessTape(args[0], 0, defines.NxCF_EXCLUDE_CRC_CHECK, 0); } else System.out.println("loading library failed"); } } |
import NxCore tapePath = "" days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] def WhatsInNDays(d, n): t = NxCore.NxDate() t.NDays = d.NDays + n NxCore.DateFromNDays(t) print("Tape date is: {} {}/{:02d}/{:02d} -- in {} days it will be {} {}/{:02d}/{:02d}".format( days[d.DayOfWeek], d.Year, d.Month, d.Day, n, days[t.DayOfWeek], t.Year, t.Month, t.Day)) return t.NDays def OnNxCoreCallback(NxCoreSys, NxCoreMsg): if NxCoreMsg.MessageType == NxCore.NxMSG_STATUS and NxCoreSys.Status == NxCore.NxCORESTATUS_RUNNING and NxCoreSys.nxTime.MsOfDay != 0: WhatsInNDays(NxCoreSys.nxDate, 5) return NxCore.NxCALLBACKRETURN_STOP return NxCore.NxCALLBACKRETURN_CONTINUE if NxCore.LoadNxCore("NxCoreAPI64.dll"): returnValue = NxCore.ProcessTape(tapePath, 0, NxCore.NxCF_EXCLUDE_CRC_CHECK, 0, OnNxCoreCallback) else: print("loading library failed") |