added wxDateTime::GetDateOnly()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -94,6 +94,7 @@ Major new features in 2.8 release
|
||||
All:
|
||||
|
||||
- Added wxSizerFlags::Shaped() and FixedMinSize() methods
|
||||
- Added wxDateTime::GetDateOnly()
|
||||
|
||||
wxMSW
|
||||
|
||||
|
@@ -862,6 +862,20 @@ Same as \helpref{Set}{wxdatetimesettm}.
|
||||
Returns {\tt true} if the object represents a valid time moment.
|
||||
|
||||
|
||||
\membersection{wxDateTime::GetDateOnly}\label{wxdatetimegetdateonly}
|
||||
|
||||
\constfunc{wxDateTime}{GetDateOnly}{\void}
|
||||
|
||||
Returns the object having the same date component as this one but time of
|
||||
00:00:00.
|
||||
|
||||
\newsince{2.8.2}
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{ResetTime}{wxdatetimeresettime}
|
||||
|
||||
|
||||
\membersection{wxDateTime::GetTm}\label{wxdatetimegettm}
|
||||
|
||||
\constfunc{Tm}{GetTm}{\param{const TimeZone\& }{tz = Local}}
|
||||
|
@@ -639,6 +639,12 @@ public:
|
||||
// resets time to 00:00:00, doesn't change the date
|
||||
wxDateTime& ResetTime();
|
||||
|
||||
#if wxABI_VERSION >= 20802
|
||||
// get the date part of this object only, i.e. the object which has the
|
||||
// same date as this one but time of 00:00:00
|
||||
wxDateTime GetDateOnly() const;
|
||||
#endif // wxABI 2.8.1+
|
||||
|
||||
// the following functions don't change the values of the other
|
||||
// fields, i.e. SetMinute() won't change either hour or seconds value
|
||||
|
||||
|
@@ -1496,6 +1496,16 @@ wxDateTime& wxDateTime::ResetTime()
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxDateTime wxDateTime::GetDateOnly() const
|
||||
{
|
||||
Tm tm = GetTm();
|
||||
tm.msec =
|
||||
tm.sec =
|
||||
tm.min =
|
||||
tm.hour = 0;
|
||||
return wxDateTime(tm);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DOS Date and Time Format functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -191,6 +191,7 @@ private:
|
||||
CPPUNIT_TEST( TestDateParse );
|
||||
CPPUNIT_TEST( TestTimeArithmetics );
|
||||
CPPUNIT_TEST( TestDSTBug );
|
||||
CPPUNIT_TEST( TestDateOnly );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void TestLeapYears();
|
||||
@@ -206,6 +207,7 @@ private:
|
||||
void TestDateParse();
|
||||
void TestTimeArithmetics();
|
||||
void TestDSTBug();
|
||||
void TestDateOnly();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(DateTimeTestCase)
|
||||
};
|
||||
@@ -920,4 +922,20 @@ void DateTimeTestCase::TestDSTBug()
|
||||
#endif // CHANGE_SYSTEM_DATE
|
||||
}
|
||||
|
||||
void DateTimeTestCase::TestDateOnly()
|
||||
{
|
||||
wxDateTime dt(19, wxDateTime::Jan, 2007, 15, 01, 00);
|
||||
|
||||
static const wxDateTime::wxDateTime_t DATE_ZERO = 0;
|
||||
CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetHour() );
|
||||
CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetMinute() );
|
||||
CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetSecond() );
|
||||
CPPUNIT_ASSERT_EQUAL( DATE_ZERO, dt.GetDateOnly().GetMillisecond() );
|
||||
|
||||
dt.ResetTime();
|
||||
CPPUNIT_ASSERT_EQUAL( wxDateTime(19, wxDateTime::Jan, 2007), dt );
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( wxDateTime::Today(), wxDateTime::Now().GetDateOnly() );
|
||||
}
|
||||
|
||||
#endif // wxUSE_DATETIME
|
||||
|
Reference in New Issue
Block a user