Hi guys,
Can anybody help me in knowing the date related functions in C or C++ using win 32.
I want to compare 2 dates and also do some operations on the date value like adding days and months .
Kindly help me
Saif
Hi guys,
Can anybody help me in knowing the date related functions in C or C++ using win 32.
I want to compare 2 dates and also do some operations on the date value like adding days and months .
Kindly help me
Saif
Write a date class, storing month,day,year as ints. ie
Then you could write some operators and, uh... stuff ... =)Code:class date { int m, d, y; public: date() : m(0),d(0),y(0) {} date(int M, int D, int Y) : m(M), d(D), y(Y) { } date(const date& dt) { m = dt.m; d = dt.d; y = dt.y; } int month() const { return m; } int day() const { return d; } int year() const { return y; } };
"He who makes a beast of himself, gets rid of the pain of being a man." Dr. Johnson
Are you using Windows? If so there are some helpful functions to aid the process. Using GetLocalTime() or GetSystemTime() and SystemTimeToFileTime() with FileTimeToSystemTime() can produce accurate dates in the form or 64-bit integers. The one major problem (in C/C++ anyway) is that there is no native support for doing 64-bit math. Your options are assembler or writing a couple of functions for doing some 64-bit addition and subtraction. Either way it is actually much easier than only using a class that maintains the date.