date class.

P

Prasad

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.

Thanks in advance.

Thanks & regards,
Prasad.
 
K

kwikius

Prasad said:
Hi All,

I want to perform some date calculations. Is there any standard class
in the C++ which will help me?

The boost date_time library is currently being discussed for inclusion
in the next version of the C++ standard:

http://www.boost.org/doc/html/date_time.html

To get it you will need to download and install the boost distro from
http://www.boost.org
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.

Boost keeps data on which of their libraries work with each compiler.
See the links from theRegression Tests heading for date_time at
http://www.boost.org. e.g:

http://tinyurl.com/nszzf

regards
Andy Little
 
H

Howard Hinnant

"Prasad said:
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.

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_extensions/Gregorian_date.html

It allows a very intuitive and error-proof construction:

date d = may/19/2006;

Or if you want the 3rd Friday in May:

date d = 3*fri/may/2006;

-Howard
 
R

Roland Pibinger

I want to perform some date calculations. Is there any standard class
in the C++ which will help me?
No

I want to perform operations like, difference between 2 date,
incrementaing the date etc.

If you want a lightweigth date class (and don't want to introduce the
complexity of Boost into your program) look for one of the freely
available date classes like zDate and the 'Killer Date class'.

Best wishes,
Roland Pibinger
 
R

Richard Herring

In message
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_extensions/Gregorian_date.html

It allows a very intuitive and error-proof construction:

date d = may/19/2006;

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.
 
H

Howard Hinnant

Richard Herring said:
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.

Thanks. And agreed. I/O is its weak point. I basically just gave up
(punted). The C++ locale system and I don't get along very well.

-Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top