Topic: C++ proposal storage
Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1997/01/29 Raw View
Alessandro Vesely wrote:
>
> Christopher Eltschka wrote:
> > class DateTime // inclomplete interface
> > {
> > public:
> > DateTime(year,month,day,hour,min,sec);
> > DateTime operator+(int sec); // Advances DateTime by sec seconds
> > int operator-(int sec); // Goes back by sec seconds
> > int operator-(DateTime); // gives the difference in seconds
> > int Year();
> > int Month();
> > int Day();
> > int Hour();
> > int Minute();
> > int Second();
>
> > int DaysOfMonth();
>
> You mean Day returns sunday ... saturday? Or is this 28/29/30/31?
>
This is 28/29/30/31. BTW, a DayOfWeek (not: DaysOfWeek) function would
be nice, too (Maybe the name of the function above (and the following
one) would better be DaysInMonth/DaysInYear).
> > int DaysOfYear();
> > };
[...]
>
> It is also good to have functions such as
>
> set_end_of_dat()
> set_end_of_month()
> set_invalid_date()
Hmmm... what would an invalid date be?
BTW, should a DateTime class handle the Julian Calendar as well?
What about Years b.C. (with a proper handling of the non-existent
Year "0")?
>
> And, of course, comparison operators.
>
Yes, certainly. And it should handle timezones correctly. Maybe with
support for summer time (easiest by giving a summer time flag
controlled by the user).
> Ciao
> Ale
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Eric Ulevik <eau@astsun.fujitsu.com.au>
Date: 1997/01/31 Raw View
------------635624212A3E2
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
Christopher Eltschka wrote:
>
> Alessandro Vesely wrote:
> >
> > Christopher Eltschka wrote:
> > > class DateTime // inclomplete interface
> >
> Yes, certainly. And it should handle timezones correctly. Maybe with
> support for summer time
Correct time zone handling would be very nice. It's also very unlikely.
A large database of rules is needed to cover time zones and summer
times. Given that the contents basically depend upon local politics, I
don't see how this can be part of any standard.
For example: The state of New South Wales in Australia swaps between
UTC+10 and UTC+11, except for the city of Broken Hill, which swaps
between UTC+9:30 and UTC+10:30.
Regards,
Eric Ulevik
------------635624212A3E2
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii
<HTML><BODY>
<DT>Christopher Eltschka wrote:<BR>
> <BR>
> Alessandro Vesely wrote:<BR>
> ><BR>
> > Christopher Eltschka wrote:<BR>
> > > class DateTime // inclomplete interface<BR>
> ><BR>
> Yes, certainly. And it should handle timezones correctly. Maybe with<BR>
> support for summer time<BR>
</DT>
<DT>Correct time zone handling would be very nice. It's also very unlikely.</DT>
<DT> </DT>
<DT>A large database of rules is needed to cover time zones and summer
times. Given that the contents basically depend upon local politics,
I don't see how this can be part of any standard.</DT>
<DT> </DT>
<DT>For example: The state of New South Wales in Australia swaps between
UTC+10 and UTC+11, except for the city of Broken Hill, which swaps between
UTC+9:30 and UTC+10:30.</DT>
<DT> </DT>
<DT>Regards,</DT>
<DT> </DT>
<DT>Eric Ulevik</DT>
</BODY>
</HTML>
------------635624212A3E2--
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Alessandro Vesely <mc6192@mclink.it>
Date: 1997/01/27 Raw View
Christopher Eltschka wrote:
> class DateTime // inclomplete interface
> {
> public:
> DateTime(year,month,day,hour,min,sec);
> DateTime operator+(int sec); // Advances DateTime by sec seconds
> int operator-(int sec); // Goes back by sec seconds
> int operator-(DateTime); // gives the difference in seconds
> int Year();
> int Month();
> int Day();
> int Hour();
> int Minute();
> int Second();
> int DaysOfMonth();
You mean Day returns sunday ... saturday? Or is this 28/29/30/31?
> int DaysOfYear();
> };[...]
> Possibly it should also contain functions to advance by a certain
> number of months/years (not trivial because of different lengths of
> months/years: You can't simply say: A year has n seconds, so add
> n to get to the next year, as you can do with hours or days.
> BTW: What is one month after 31. Jan.? Or one year after
> 29. Feb. 1996?)
It is 28 (29 on leap years) Feb and 28 Feb 1997 respectively. This implies
date d + 1 month - 1 month may be != d. But adjusting this sort of thing
is exactly what add_months(n) or add_years(n) are supposed to do.
It is also good to have functions such as
set_end_of_dat()
set_end_of_month()
set_invalid_date()
And, of course, comparison operators.
Ciao
Ale
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: d96-mst@nada.kth.se (Mikael Steldal)
Date: 1997/01/24 Raw View
In article <rf5d8uyowvx.fsf@vx.cit.alcatel.fr>,
James Kanze <james-albert.kanze@vx.cit.alcatel.fr> wrote:
>I'd also stress the fact that the presence of a proposal at such a site
>would not mean "this must be adopted by C++ in the next revision of the
>standard", but only "if we want this, here is how it should be done".
I want a DateTime class.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Date: 1997/01/24 Raw View
Mikael Steldal wrote:
> I want a DateTime class.
With what interface?
A minimum interface should probably contain at least the following:
class DateTime // inclomplete interface
{
public:
DateTime(year,month,day,hour,min,sec);
DateTime operator+(int sec); // Advances DateTime by sec seconds
int operator-(int sec); // Goes back by sec seconds
int operator-(DateTime); // gives the difference in seconds
int Year();
int Month();
int Day();
int Hour();
int Minute();
int Second();
int DaysOfMonth();
int DaysOfYear();
};
ostream& operator<<(ostream&, DateTime);
// should support localisation, maybe with manipulators.
Possibly it should also contain functions to advance by a certain
number of months/years (not trivial because of different lengths of
months/years: You can't simply say: A year has n seconds, so add
n to get to the next year, as you can do with hours or days.
BTW: What is one month after 31. Jan.? Or one year after
29. Feb. 1996?)
In addition there should be a standard function to get current
date/time, say now(). To have standard DayOfWeek() and WeekOfYear()
functions would be nice, too.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]