diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-03-07 13:19:22 +0100 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-03-08 17:50:58 +0100 |
commit | 09c3b8ab70b115aaea8fe68557da2cc5edde4181 (patch) | |
tree | 50dca746af318aa8c6bd488c48eaeeab33845cb1 | |
parent | 066dcba00659d2f81e4ba67edd14c44ed9ec3ea2 (diff) |
unotools: extractDate and extractTime functions
Added a pair of functions to split a UNO DateTime object into the
corresponding Date and Time objects.
Change-Id: I6bf31d83b3843a9482d6bf538a5dd7130c2c7046
-rw-r--r-- | include/unotools/datetime.hxx | 3 | ||||
-rw-r--r-- | unotools/source/misc/datetime.cxx | 17 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/unotools/datetime.hxx b/include/unotools/datetime.hxx index 3887df2df5e2..7611299e38e2 100644 --- a/include/unotools/datetime.hxx +++ b/include/unotools/datetime.hxx @@ -44,6 +44,9 @@ namespace utl UNOTOOLS_DLLPUBLIC void typeConvert(const DateTime& _rDateTime, starutil::DateTime& _rOut); UNOTOOLS_DLLPUBLIC void typeConvert(const starutil::DateTime& _rDateTime, DateTime& _rOut); + UNOTOOLS_DLLPUBLIC void extractDate(const starutil::DateTime& _rDateTime, starutil::Date& _rOut); + UNOTOOLS_DLLPUBLIC void extractTime(const starutil::DateTime& _rDateTime, starutil::Time& _rOut); + UNOTOOLS_DLLPUBLIC ::rtl::OUString toISO8601(const starutil::DateTime& _rDateTime); UNOTOOLS_DLLPUBLIC bool ISO8601parseDateTime(const ::rtl::OUString &i_rIn, starutil::DateTime& o_rDateTime); UNOTOOLS_DLLPUBLIC bool ISO8601parseDate(const ::rtl::OUString &i_rIn, starutil::Date& o_rDate); diff --git a/unotools/source/misc/datetime.cxx b/unotools/source/misc/datetime.cxx index 068209489d6d..96de5106f388 100644 --- a/unotools/source/misc/datetime.cxx +++ b/unotools/source/misc/datetime.cxx @@ -215,6 +215,23 @@ void typeConvert(const starutil::DateTime& _rDateTime, DateTime& _rOut) } +void extractDate(const starutil::DateTime& _rDateTime, starutil::Date& _rOut) +{ + _rOut.Day = _rDateTime.Day; + _rOut.Month = _rDateTime.Month; + _rOut.Year = _rDateTime.Year; +} + + +void extractTime(const starutil::DateTime& _rDateTime, starutil::Time& _rOut) +{ + _rOut.Hours = _rDateTime.Hours; + _rOut.Minutes = _rDateTime.Minutes; + _rOut.Seconds = _rDateTime.Seconds; + _rOut.NanoSeconds = _rDateTime.NanoSeconds; +} + + OUString toISO8601(const starutil::DateTime& rDateTime) { OUStringBuffer rBuffer; |