In message
<howard.hinnant-C6A935.10320919052006@syrcnyrdrs-02-ge0.nyroc.rr.com>,
Howard Hinnant <howard.hinnant@gmail.com> writes[color=blue]
>In article <1148027972.556427.246170@38g2000cwa.googlegroups. com>,
> "Prasad" <prasadjoshi_aol@yahoo.co.in> wrote:
>[color=green]
>> Hi All,
>>
>> I want to perform some date calculations. Is there any standard class
>> in the C++ which will help me?
>>
>> I want to perform operations like, difference between 2 date,
>> incrementaing the date etc.
>>
>> I am working on SUSE 10 (LINUX kind of os). And using g++ and c++ for
>> comilations.[/color]
>
>In addition to the boost suggestion (which is a good suggestion), here's
>a date class with a cute syntax:
>
>
http://home.twcny.rr.com/hinnant/cpp...rian_date.html
>
>It allows a very intuitive and error-proof construction:
>
>date d = may/19/2006;[/color]
Interesting and ingenious. But I think there might be an argument for
_not_ using the locale to determine the default output format, but
instead to use the unambiguous ISO standard format yyyy-mm-dd.
(
http://www.cl.cam.ac.uk/~mgk25/iso-time.html)
There's no reason why it can't be more liberal in what it accepts for
input, and maybe add a locale-dependent user-formatted output function
as well.
The default "C" locale's format is unfortunately horribly ambiguous. You
may think 10/12/50 was in October, but I happen to know it was December,
and if you live in Thailand it won't happen until next year. 1950-12-10
is unambiguous, *and* as a bonus you can sort it lexicographically.
[color=blue]
>
>Or if you want the 3rd Friday in May:
>
>date d = 3*fri/may/2006;
>[/color]
--
Richard Herring