473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

date class.

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.

May 19 '06 #1
6 3428
you can use boost

May 19 '06 #2

Prasad wrote:
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

May 19 '06 #3
In article <11**********************@38g2000cwa.googlegroups. com>,
"Prasad" <pr*************@yahoo.co.in> wrote:
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...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
May 19 '06 #4
On 19 May 2006 01:39:32 -0700, "Prasad" <pr*************@yahoo.co.in>
wrote:
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
May 19 '06 #5
In message
<ho**********************************@syrcnyrdrs-02-ge0.nyroc.rr.com>,
Howard Hinnant <ho************@gmail.com> writes
In article <11**********************@38g2000cwa.googlegroups. com>,
"Prasad" <pr*************@yahoo.co.in> wrote:
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...rian_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.

Or if you want the 3rd Friday in May:

date d = 3*fri/may/2006;


--
Richard Herring
May 26 '06 #6
In article <Uw**************@baesystems.com>,
Richard Herring <ju**@[127.0.0.1]> wrote:
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
May 26 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ESPNSTI | last post by:
Hi, I'd like to be able to distinguish between a DateTime variable that is allowed to hold both date and time and a DateTime variable that is allowed to only hold a Date. The reason's for this...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
9
by: newtophp2000 | last post by:
I need to add the ability for the users to select a date on one of our web pages. The examples I was given by some users were in JavaScript. Is there a free date picker that I can use? I saw one...
10
by: Henrik Dahl | last post by:
Hello! I have an xml schema which has a date typed attribute. I have used xsd.exe to create a class library for XmlSerializer. The result of XmlSerializer.Serialize(...) should be passed as the...
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
1
by: aRTx | last post by:
<? /* Directory Listing Script - Version 2 ==================================== Script Author: Artani <artan_p@msn.com>. www.artxcenter.com REQUIREMENTS ============ This script requires...
1
osward
by: osward | last post by:
Hi everyone, Background 1. I have a table that consits 400+ rows of data and is growing by day. The table already has paging links at the bottom but I restricted to display rows of data only >=...
2
by: Andrus | last post by:
I need to display and edit only date part in DataGridView column whose data source type is DateTime?. The following code shows and allows to edit also time part. How to modify this code so that...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
7
by: kr151080 | last post by:
Ok so I am messing around with a program and have no idea how to go about doing this but here is the code for the class date.... public class Date { private int dMonth; private int dDay;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.