* 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:
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _DATE_TIME_H_
|
#ifndef _DATE_TIME_H_
|
||||||
@@ -147,6 +147,7 @@ class BDate {
|
|||||||
|
|
||||||
class BDateTime {
|
class BDateTime {
|
||||||
public:
|
public:
|
||||||
|
BDateTime();
|
||||||
BDateTime(const BDate &date, const BTime &time);
|
BDateTime(const BDate &date, const BTime &time);
|
||||||
~BDateTime();
|
~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.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -430,6 +430,11 @@ BDate::AddMonths(int32 months)
|
|||||||
fYear--;
|
fYear--;
|
||||||
fMonth += 12;
|
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());
|
fDay = min_c(fDay, DaysInMonth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,10 +541,11 @@ bool
|
|||||||
BDate::IsLeapYear(int32 year) const
|
BDate::IsLeapYear(int32 year) const
|
||||||
{
|
{
|
||||||
if (year < 1582) {
|
if (year < 1582) {
|
||||||
if (year < 0) year++;
|
if (year < 0)
|
||||||
|
year++;
|
||||||
return (year % 4) == 0;
|
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
|
// #pragma mark - BDateTime
|
||||||
|
|
||||||
|
|
||||||
|
BDateTime::BDateTime()
|
||||||
|
: fDate(BDate()),
|
||||||
|
fTime(BTime())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
BDateTime::BDateTime(const BDate &date, const BTime &time)
|
BDateTime::BDateTime(const BDate &date, const BTime &time)
|
||||||
: fDate(date),
|
: fDate(date),
|
||||||
fTime(time)
|
fTime(time)
|
||||||
@@ -845,6 +857,10 @@ BDateTime::SetTime(const BTime &time)
|
|||||||
uint32
|
uint32
|
||||||
BDateTime::Time_t() const
|
BDateTime::Time_t() const
|
||||||
{
|
{
|
||||||
|
BDate date(1970, 1, 1);
|
||||||
|
if (date.Difference(fDate) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
tm tm_struct;
|
tm tm_struct;
|
||||||
|
|
||||||
tm_struct.tm_hour = fTime.Hour();
|
tm_struct.tm_hour = fTime.Hour();
|
||||||
|
|||||||
Reference in New Issue
Block a user