Connecting Tech Pros Worldwide Forums | Help | Site Map

date class.

Prasad
Guest
 
Posts: n/a
#1: May 19 '06
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.

zqzhangster@gmail.com
Guest
 
Posts: n/a
#2: May 19 '06

re: date class.


you can use boost

kwikius
Guest
 
Posts: n/a
#3: May 19 '06

re: date class.



Prasad wrote:[color=blue]
> Hi All,
>
> I want to perform some date calculations. Is there any standard class
> in the C++ which will help me?[/color]

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
[color=blue]
> 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]

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

Howard Hinnant
Guest
 
Posts: n/a
#4: May 19 '06

re: date class.


In article <1148027972.556427.246170@38g2000cwa.googlegroups. com>,
"Prasad" <prasadjoshi_aol@yahoo.co.in> wrote:
[color=blue]
> 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;

Or if you want the 3rd Friday in May:

date d = 3*fri/may/2006;

-Howard
Roland Pibinger
Guest
 
Posts: n/a
#5: May 19 '06

re: date class.


On 19 May 2006 01:39:32 -0700, "Prasad" <prasadjoshi_aol@yahoo.co.in>
wrote:[color=blue]
>I want to perform some date calculations. Is there any standard class
>in the C++ which will help me?[/color]

No
[color=blue]
>I want to perform operations like, difference between 2 date,
>incrementaing the date etc.[/color]

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
Richard Herring
Guest
 
Posts: n/a
#6: May 26 '06

re: date class.


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
Howard Hinnant
Guest
 
Posts: n/a
#7: May 26 '06

re: date class.


In article <UwRrrNJ1UtdEFwTZ@baesystems.com>,
Richard Herring <junk@[127.0.0.1]> wrote:
[color=blue]
> 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.[/color]

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
Closed Thread