diff options
author | Noel Grandin <noel@peralex.com> | 2015-01-11 13:35:38 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-01-13 15:24:04 +0000 |
commit | c32a5a3b8e2e3a49ac9f1fd3f2872b00612676b7 (patch) | |
tree | cb2de3eab8dbbcff359d367177d91b67725e1b69 /tools | |
parent | 86db1702d72a103ffeafc69dcaa63318539c147a (diff) |
simplify Date/Time/DateTime conversion code
add constructors to Date/DateTime/Time,
that take the css::util counterparts,
to simplify code converting between these type
Change-Id: I4b03da02c63f65b6ec18cb4d6ecc3859bdef1ff7
Reviewed-on: https://gerrit.libreoffice.org/13855
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/datetime/datetime.cxx | 6 | ||||
-rw-r--r-- | tools/source/datetime/tdate.cxx | 5 | ||||
-rw-r--r-- | tools/source/datetime/ttime.cxx | 5 |
3 files changed, 16 insertions, 0 deletions
diff --git a/tools/source/datetime/datetime.cxx b/tools/source/datetime/datetime.cxx index 667eef6efc56..8399415cd802 100644 --- a/tools/source/datetime/datetime.cxx +++ b/tools/source/datetime/datetime.cxx @@ -19,6 +19,12 @@ #include <tools/datetime.hxx> #include <rtl/math.hxx> +DateTime::DateTime( const css::util::DateTime& rDateTime ) + : Date( rDateTime.Day, rDateTime.Month, rDateTime.Year ), + Time( rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds, rDateTime.NanoSeconds ) +{ +} + bool DateTime::IsBetween( const DateTime& rFrom, const DateTime& rTo ) const { if ( (*this >= rFrom) && (*this <= rTo) ) diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx index e1e640d87dff..b970d51da5ba 100644 --- a/tools/source/datetime/tdate.cxx +++ b/tools/source/datetime/tdate.cxx @@ -158,6 +158,11 @@ Date::Date( DateInitSystem ) #endif } +Date::Date( const ::com::sun::star::util::DateTime& rDateTime ) +{ + init( rDateTime.Day, rDateTime.Month, rDateTime.Year ); +} + void Date::SetDay( sal_uInt16 nNewDay ) { sal_uIntPtr nMonth = GetMonth(); diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index d5b83a3ad7de..6f764569d490 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -148,6 +148,11 @@ Time::Time( const ::com::sun::star::util::Time &_rTime ) { init(_rTime.Hours, _rTime.Minutes, _rTime.Seconds, _rTime.NanoSeconds); } +Time::Time( const ::com::sun::star::util::DateTime &_rDateTime ) +{ + init(_rDateTime.Hours, _rDateTime.Minutes, _rDateTime.Seconds, _rDateTime.NanoSeconds); +} + void tools::Time::init( sal_uInt32 nHour, sal_uInt32 nMin, sal_uInt32 nSec, sal_uInt64 nNanoSec ) { // normalize time |