* add default constructor
* fix broken Time_t function * take the missing days into account when adding months git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29713 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a869d32e0c
commit
c26731ec52
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DATE_TIME_H_
|
||||
@ -147,6 +147,7 @@ class BDate {
|
||||
|
||||
class BDateTime {
|
||||
public:
|
||||
BDateTime();
|
||||
BDateTime(const BDate &date, const BTime &time);
|
||||
~BDateTime();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2008, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2007-2009, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@ -430,6 +430,11 @@ BDate::AddMonths(int32 months)
|
||||
fYear--;
|
||||
fMonth += 12;
|
||||
}
|
||||
|
||||
// 'missing' days between switch julian - gregorian
|
||||
if (fYear == 1582 && fMonth == 10 && fDay > 4 && fDay < 15)
|
||||
fDay = (months > 0) ? 15 : 4;
|
||||
|
||||
fDay = min_c(fDay, DaysInMonth());
|
||||
}
|
||||
|
||||
@ -536,10 +541,11 @@ bool
|
||||
BDate::IsLeapYear(int32 year) const
|
||||
{
|
||||
if (year < 1582) {
|
||||
if (year < 0) year++;
|
||||
if (year < 0)
|
||||
year++;
|
||||
return (year % 4) == 0;
|
||||
}
|
||||
return year % 400 == 0 || year % 4 == 0 && year % 100 != 0;
|
||||
return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
|
||||
}
|
||||
|
||||
|
||||
@ -777,6 +783,12 @@ BDate::_DateToJulianDay(int32 _year, int32 month, int32 day) const
|
||||
// #pragma mark - BDateTime
|
||||
|
||||
|
||||
BDateTime::BDateTime()
|
||||
: fDate(BDate()),
|
||||
fTime(BTime())
|
||||
{
|
||||
}
|
||||
|
||||
BDateTime::BDateTime(const BDate &date, const BTime &time)
|
||||
: fDate(date),
|
||||
fTime(time)
|
||||
@ -845,6 +857,10 @@ BDateTime::SetTime(const BTime &time)
|
||||
uint32
|
||||
BDateTime::Time_t() const
|
||||
{
|
||||
BDate date(1970, 1, 1);
|
||||
if (date.Difference(fDate) < 0)
|
||||
return -1;
|
||||
|
||||
tm tm_struct;
|
||||
|
||||
tm_struct.tm_hour = fTime.Hour();
|
||||
|
Loading…
Reference in New Issue
Block a user