Incrementing dates outside of a GUI

I need to loop over data organized by date (month/day/year). In the interactive GUI I wrote, this is dead easy - I use TGNumberEntry with the appropriate format and call

 Now that the interactive stuff works, it is time to automate. So I need to increment the date in non-gui code. Is there a way to get just the number-handling aspects of TGNumberEntry. Even TGNumberEntryField seems to require a parent windo.

It is ==>very <== handy to have pre-written code that increments dates properly.


Hi Chris,

Use the TDatime::Set functions


Here is the code I nees to replace:

// fDateEntry is a TGNumberEntry pointer…
while( date <= dateLast ) {
fDateEntry->GetNumberEntry()->GetDate(fYear, fMonth, fDay); // Root uses YMD :wink:
fMipA->GetInformation(fSite, fMonth, fDay, fYear); // CIT uses MDY
fMipB->GetInformation(fSite, fMonth, fDay, fYear); // CIT uses MDY
fDateEntry->IncreaseNumber(); // takes care of incrementing months etc…
date = fDateEntry->GetNumberEntry()->GetIntNumber();

So I can use TDatime::Set to set the initial date and whatnot. However. fDateEntry knows how to go from February 28 to either March 1 or Feb 29 depending on the year. I don’t see the equivalent of IncreaseNumber() in fDatime.



[quote=“brun”]Hi Chris,

Use the TDatime::Set functions


I’m trying to use TDatime to define a start and an arbitrary stop time. This will require manipulating months and years (adding and subtracting), properly accounting for different length months.

Is TDatime the proper class to use? I don’t see any way to add a month (or a year or a day…).


I do not understand your question. TDatime has the interface to build a TDatime object starting from date/time or/and year/month/day/hour/min/sec
You can compare 2 TDatime objects (say d1 and d2) with eg

TDatime d1(2007,02,21,10,45,56); TDatime d2( some other date/time); test if another date d3 is in the range with

if (d3.Get() >d1.Get() && d3.Get() <= d2.Get()) { //I am in the selected date range }