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 /include/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 'include/tools')
-rw-r--r-- | include/tools/date.hxx | 2 | ||||
-rw-r--r-- | include/tools/datetime.hxx | 7 | ||||
-rw-r--r-- | include/tools/time.hxx | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/include/tools/date.hxx b/include/tools/date.hxx index b0f1612f5bed..0fc4109c42f7 100644 --- a/include/tools/date.hxx +++ b/include/tools/date.hxx @@ -21,6 +21,7 @@ #include <tools/toolsdllapi.h> #include <com/sun/star/util/Date.hpp> +#include <com/sun/star/util/DateTime.hpp> #include <sal/log.hxx> enum DayOfWeek { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, @@ -61,6 +62,7 @@ public: SAL_WARN_IF(_rDate.Year < 0, "tools.datetime", "Negative year in css::util::Date to ::Date conversion"); init(_rDate.Day, _rDate.Month, _rDate.Year); } + Date( const ::com::sun::star::util::DateTime& _rDateTime ); void SetDate( sal_uInt32 nNewDate ) { nDate = nNewDate; } sal_uInt32 GetDate() const { return nDate; } diff --git a/include/tools/datetime.hxx b/include/tools/datetime.hxx index 256bb7258622..295c587d3b91 100644 --- a/include/tools/datetime.hxx +++ b/include/tools/datetime.hxx @@ -22,6 +22,7 @@ #include <tools/toolsdllapi.h> #include <tools/date.hxx> #include <tools/time.hxx> +#include <com/sun/star/util/DateTime.hpp> class TOOLS_DLLPUBLIC SAL_WARN_UNUSED DateTime : public Date, public tools::Time { @@ -45,6 +46,12 @@ public: DateTime( const tools::Time& rTime ) : Date(0), Time( rTime ) {} DateTime( const Date& rDate, const tools::Time& rTime ) : Date( rDate ), Time( rTime ) {} + DateTime( const css::util::DateTime& rDateTime ); + + css::util::DateTime + GetUNODateTime() const + { return css::util::DateTime(GetNanoSec(), GetSec(), GetMin(), GetHour(), + GetDay(), GetMonth(), GetYear(), false); } bool IsBetween( const DateTime& rFrom, const DateTime& rTo ) const; diff --git a/include/tools/time.hxx b/include/tools/time.hxx index 140b69ffb4db..1ece6c4c209a 100644 --- a/include/tools/time.hxx +++ b/include/tools/time.hxx @@ -22,6 +22,7 @@ #include <tools/toolsdllapi.h> #include <tools/solar.h> #include <com/sun/star/util/Time.hpp> +#include <com/sun/star/util/DateTime.hpp> /** @WARNING: This class can serve both as wall clock time and time duration, and @@ -69,6 +70,7 @@ public: Time( sal_Int64 _nTime ) { Time::nTime = _nTime; } Time( const tools::Time& rTime ); Time( const ::com::sun::star::util::Time& rTime ); + Time( const ::com::sun::star::util::DateTime& rDateTime ); Time( sal_uInt32 nHour, sal_uInt32 nMin, sal_uInt32 nSec = 0, sal_uInt64 nNanoSec = 0 ); |