TreatmentPlant wrote:
> Ulrich Eckhardt wrote:
>> TreatmentPlant wrote:
>>> I am having a lot of trouble trying to work with dates.
>>>
>>> I am looking for a simple script to return true if the date today is
>>> after a particular date, say 27 April 2006, false otherwise.
>>>
>>> I know this is a simple request, but none of my books have anything
>>> dealing with dates, and Google isn't doing too much for me either?
>>
>> If you have the date in a string like "27 April 2006", you can split
>> it up
>> in three numbers ("April" will have to become 4). You can then say: 1.
>> If the year of today is greater than the year, it is after today.
>> 2. If the year of today is smaller, then it is before today
>> 3. If neither is true, i.e. the years are equal, you need to look at the
>> months where the same principle of ordering applies.
>>
>> Otherwise I would have a look at Boost's DateTime library.
>>
>> Uli
>>
> POSTED AT:
> alt.comp.lang.learn.c-c++
> comp.lang.c++
>
> Surely I don't have to go to Boost and get 10MB of header files just to
> solve this problem!! That seems incredible.
>
> It is such a really simple problem... all I want to do is compare two
> dates, one is today and the other is a hard coded date. Nothing in any
> of my books shows me how to do it. All the sites I have visited are
> trying to show me how to make timers, stopwatches etc.
>
> I just want to programmatic way to find if today's date is before or
> after a specified date. 27 April 2006 was just an example.
>
> Please help.
Thanks to all those that offered assistance.
I have the problem sorted out now.
It seems that when you use struct tm , you need to provide ALL the
values for the time and date, when the documentation I have says you
don't need to!
Thanks again!
|