LibreOffice Module tools (master) 1
|
#include <datetime.hxx>
Public Types | |
enum | DateTimeInitSystem { SYSTEM } |
enum | DateTimeInitEmpty { EMPTY } |
Public Types inherited from Date | |
enum | DateInitSystem { SYSTEM } |
enum | DateInitEmpty { EMPTY } |
Public Types inherited from tools::Time | |
enum | TimeInitSystem { SYSTEM } |
enum | TimeInitEmpty { EMPTY } |
Public Member Functions | |
DateTime (DateTimeInitEmpty) | |
DateTime (DateTimeInitSystem) | |
DateTime (const DateTime &rDateTime) | |
DateTime (const Date &rDate) | |
DateTime (const tools::Time &rTime) | |
DateTime (const Date &rDate, const tools::Time &rTime) | |
DateTime (const css::util::DateTime &rDateTime) | |
css::util::DateTime | GetUNODateTime () const |
bool | IsBetween (const DateTime &rFrom, const DateTime &rTo) const |
bool | IsEqualIgnoreNanoSec (const DateTime &rDateTime) const |
bool | operator== (const DateTime &rDateTime) const |
bool | operator!= (const DateTime &rDateTime) const |
bool | operator> (const DateTime &rDateTime) const |
bool | operator< (const DateTime &rDateTime) const |
bool | operator>= (const DateTime &rDateTime) const |
bool | operator<= (const DateTime &rDateTime) const |
sal_Int64 | GetSecFromDateTime (const Date &rDate) const |
void | ConvertToUTC () |
void | ConvertToLocalTime () |
void | AddTime (double fTimeInDays) |
DateTime & | operator+= (const tools::Time &rTime) |
DateTime & | operator-= (const tools::Time &rTime) |
DateTime & | operator+= (const tools::Duration &rDuration) |
Duration can be negative, so adding it will subtract its value. More... | |
DateTime & | operator= (const DateTime &rDateTime) |
DateTime & | operator= (const css::util::DateTime &rUDateTime) |
void | GetWin32FileDateTime (sal_uInt32 &rLower, sal_uInt32 &rUpper) const |
Public Member Functions inherited from Date | |
Date (DateInitEmpty) | |
Date (DateInitSystem) | |
Date (sal_Int32 nDate) | |
Date (const Date &rDate) | |
Date (sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear) | |
nDay and nMonth both must be <100, nYear must be != 0 More... | |
Date (const css::util::Date &rUDate) | |
Date (const css::util::DateTime &_rDateTime) | |
bool | IsEmpty () const |
void | SetDate (sal_Int32 nNewDate) |
sal_Int32 | GetDate () const |
sal_uInt32 | GetDateUnsigned () const |
Type safe access for values that are guaranteed to be unsigned, like Date::SYSTEM. More... | |
css::util::Date | GetUNODate () const |
void | SetDay (sal_uInt16 nNewDay) |
nNewDay must be <100 More... | |
void | SetMonth (sal_uInt16 nNewMonth) |
nNewMonth must be <100 More... | |
void | SetYear (sal_Int16 nNewYear) |
nNewYear must be != 0 More... | |
sal_uInt16 | GetDay () const |
sal_uInt16 | GetMonth () const |
sal_Int16 | GetYear () const |
sal_uInt16 | GetYearUnsigned () const |
Type safe access for values that are guaranteed to be unsigned, like Date::SYSTEM. More... | |
sal_Int16 | GetNextYear () const |
sal_Int16 | GetPrevYear () const |
void | AddYears (sal_Int16 nAddYears) |
Add years skipping year 0 and truncating at limits. More... | |
void | AddMonths (sal_Int32 nAddMonths) |
Add months skipping year 0 and truncating at limits. More... | |
void | AddDays (sal_Int32 nAddDays) |
Add days skipping year 0 and truncating at limits. More... | |
DayOfWeek | GetDayOfWeek () const |
Obtain the day of the week for the date. More... | |
sal_uInt16 | GetDayOfYear () const |
Obtain the day of the year for the date. More... | |
sal_uInt16 | GetWeekOfYear (DayOfWeek eStartDay=MONDAY, sal_Int16 nMinimumNumberOfDaysInWeek=4) const |
Obtain the week of the year for a date. More... | |
sal_uInt16 | GetDaysInMonth () const |
Obtain the number of days in the month of the year of the date. More... | |
sal_uInt16 | GetDaysInYear () const |
bool | IsLeapYear () const |
bool | IsValidAndGregorian () const |
If the represented date is valid (1<=month<=12, 1<=day<=(28,29,30,31) depending on month/year) AND is of the Gregorian calendar (1582-10-15 <= date) More... | |
bool | IsValidDate () const |
If the represented date is valid (1<=month<=12, 1<=day<=(28,29,30,31) depending on month/year) More... | |
bool | IsEndOfMonth () const |
void | Normalize () |
Normalize date, invalid day or month values are adapted such that they carry over to the next month or/and year, for example 1999-02-32 becomes 1999-03-04, 1999-13-01 becomes 2000-01-01, 1999-13-42 becomes 2000-02-11. More... | |
bool | IsBetween (const Date &rFrom, const Date &rTo) const |
bool | operator== (const Date &rDate) const |
bool | operator!= (const Date &rDate) const |
bool | operator> (const Date &rDate) const |
bool | operator< (const Date &rDate) const |
bool | operator>= (const Date &rDate) const |
bool | operator<= (const Date &rDate) const |
Date & | operator= (const Date &rDate) |
Date & | operator= (const css::util::Date &rUDate) |
Date & | operator++ () |
Date & | operator-- () |
Public Member Functions inherited from tools::Time | |
Time (TimeInitEmpty) | |
Time (TimeInitSystem) | |
Time (sal_Int64 _nTime) | |
Time (const tools::Time &rTime) | |
Time (const css::util::Time &rTime) | |
Time (const css::util::DateTime &rDateTime) | |
Time (sal_uInt32 nHour, sal_uInt32 nMin, sal_uInt32 nSec=0, sal_uInt64 nNanoSec=0) | |
void | SetTime (sal_Int64 nNewTime) |
sal_Int64 | GetTime () const |
css::util::Time | GetUNOTime () const |
void | SetHour (sal_uInt16 nNewHour) |
void | SetMin (sal_uInt16 nNewMin) |
void | SetSec (sal_uInt16 nNewSec) |
void | SetNanoSec (sal_uInt32 nNewNanoSec) |
sal_uInt16 | GetHour () const |
sal_uInt16 | GetMin () const |
sal_uInt16 | GetSec () const |
sal_uInt32 | GetNanoSec () const |
sal_Int32 | GetMSFromTime () const |
void | MakeTimeFromMS (sal_Int32 nMS) |
sal_Int64 | GetNSFromTime () const |
void | MakeTimeFromNS (sal_Int64 nNS) |
double | GetTimeInDays () const |
12 hours == 0.5 days More... | |
bool | IsEqualIgnoreNanoSec (const tools::Time &rTime) const |
bool | operator== (const tools::Time &rTime) const |
bool | operator!= (const tools::Time &rTime) const |
bool | operator> (const tools::Time &rTime) const |
bool | operator< (const tools::Time &rTime) const |
bool | operator>= (const tools::Time &rTime) const |
bool | operator<= (const tools::Time &rTime) const |
tools::Time & | operator= (const tools::Time &rTime) |
Time | operator- () const |
tools::Time & | operator+= (const tools::Time &rTime) |
tools::Time & | operator-= (const tools::Time &rTime) |
Static Public Member Functions | |
static double | Sub (const DateTime &rDateTime1, const DateTime &rDateTime2) |
Use Sub() if the floating point "time in days" value is to be processed. More... | |
static DateTime | CreateFromWin32FileDateTime (sal_uInt32 rLower, sal_uInt32 rUpper) |
static DateTime | CreateFromUnixTime (const double fSecondsSinceEpoch) |
Creates DateTime given a unix time, which is the number of seconds elapsed since Jan 1st, 1970. More... | |
Static Public Member Functions inherited from Date | |
static sal_uInt16 | GetDaysInMonth (sal_uInt16 nMonth, sal_Int16 nYear) |
Obtain number of days in a month of a year. More... | |
static sal_Int32 | DateToDays (sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear) |
Internally normalizes values. More... | |
static bool | IsValidDate (sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear) |
Semantically identical to IsValidDate() member method. More... | |
static bool | IsEndOfMonth (sal_uInt16 nDay, sal_uInt16 nMonth, sal_Int16 nYear) |
Semantically identical to IsEndOfMonth() member method. More... | |
static bool | Normalize (sal_uInt16 &rDay, sal_uInt16 &rMonth, sal_Int16 &rYear) |
Semantically identical to Normalize() member method. More... | |
Static Public Member Functions inherited from tools::Time | |
static void | GetClock (double fTimeInDays, sal_uInt16 &nHour, sal_uInt16 &nMinute, sal_uInt16 &nSecond, double &fFractionOfSecond, int nFractionDecimals) |
Get the wall clock time particles for a (date+)time value. More... | |
static Time | GetUTCOffset () |
static sal_uInt64 | GetSystemTicks () |
Elapsed time in milliseconds (1e-3) since some unspecified starting point. More... | |
static sal_uInt64 | GetMonotonicTicks () |
Elapsed time in microseconds (1e-6) since some unspecified starting point. More... | |
Private Member Functions | |
void | NormalizeTimeRemainderAndApply (tools::Time &rTime) |
Friends | |
TOOLS_DLLPUBLIC friend DateTime | operator+ (const DateTime &rDateTime, sal_Int32 nDays) |
TOOLS_DLLPUBLIC friend DateTime | operator- (const DateTime &rDateTime, sal_Int32 nDays) |
TOOLS_DLLPUBLIC friend DateTime | operator+ (const DateTime &rDateTime, double fTimeInDays) |
TOOLS_DLLPUBLIC friend DateTime | operator- (const DateTime &rDateTime, double fTimeInDays) |
TOOLS_DLLPUBLIC friend DateTime | operator+ (const DateTime &rDateTime, const tools::Time &rTime) |
TOOLS_DLLPUBLIC friend DateTime | operator- (const DateTime &rDateTime, const tools::Time &rTime) |
TOOLS_DLLPUBLIC friend tools::Duration | operator- (const DateTime &rDateTime1, const DateTime &rDateTime2) |
Use operator-() if a duration is to be remembered or processed. More... | |
TOOLS_DLLPUBLIC friend sal_Int64 | operator- (const DateTime &rDateTime, const Date &rDate) |
TOOLS_DLLPUBLIC friend DateTime | operator+ (const DateTime &rDateTime, const tools::Duration &rDuration) |
Duration can be negative, so adding it will subtract its value. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from tools::Time | |
static const sal_Int64 | hourPerDay = 24 |
static const sal_Int64 | minutePerHour = 60 |
static const sal_Int64 | secondPerMinute = 60 |
static const sal_Int64 | nanoSecPerSec = 1000000000 |
static const sal_Int64 | nanoSecPerMinute = nanoSecPerSec * secondPerMinute |
static const sal_Int64 | nanoSecPerHour = nanoSecPerSec * secondPerMinute * minutePerHour |
static const sal_Int64 | nanoSecPerDay = nanoSecPerSec * secondPerMinute * minutePerHour * hourPerDay |
static const sal_Int64 | secondPerHour = secondPerMinute * minutePerHour |
static const sal_Int64 | secondPerDay = secondPerMinute * minutePerHour * hourPerDay |
static const sal_Int64 | minutePerDay = minutePerHour * hourPerDay |
static const sal_Int64 | nanoPerMicro = 1000 |
static const sal_Int64 | nanoPerMilli = 1000000 |
static const sal_Int64 | nanoPerCenti = 10000000 |
Definition at line 34 of file datetime.hxx.
Enumerator | |
---|---|
EMPTY |
Definition at line 42 of file datetime.hxx.
Enumerator | |
---|---|
SYSTEM |
Definition at line 37 of file datetime.hxx.
|
inlineexplicit |
Definition at line 47 of file datetime.hxx.
Referenced by CreateFromUnixTime(), and CreateFromWin32FileDateTime().
|
explicit |
Definition at line 26 of file datetime.cxx.
References Date::Date(), EMPTY, GetSystemDateTime(), Date::operator=(), tools::Time::SetTime(), and Time.
|
inline |
Definition at line 49 of file datetime.hxx.
References Time.
|
inline |
Definition at line 51 of file datetime.hxx.
References Time.
|
inline |
Definition at line 52 of file datetime.hxx.
References Time.
|
inline |
Definition at line 53 of file datetime.hxx.
References Time.
DateTime::DateTime | ( | const css::util::DateTime & | rDateTime | ) |
void DateTime::AddTime | ( | double | fTimeInDays | ) |
Definition at line 183 of file datetime.cxx.
References operator+=().
|
inline |
Definition at line 86 of file datetime.hxx.
References tools::Time::GetUTCOffset().
|
inline |
Definition at line 85 of file datetime.hxx.
References tools::Time::GetUTCOffset().
|
static |
Creates DateTime given a unix time, which is the number of seconds elapsed since Jan 1st, 1970.
Definition at line 271 of file datetime.cxx.
References Date::AddDays(), Date::Date(), DateTime(), tools::Time::nanoSecPerDay, tools::Time::nanoSecPerHour, tools::Time::nanoSecPerMinute, tools::Time::nanoSecPerSec, and SAL_WARN_IF.
|
static |
Definition at line 240 of file datetime.cxx.
References Date::AddDays(), Date::Date(), DateTime(), tools::Time::nanoSecPerHour, tools::Time::nanoSecPerMinute, tools::Time::nanoSecPerSec, and SAL_WARN_IF.
sal_Int64 DateTime::GetSecFromDateTime | ( | const Date & | rDate | ) | const |
Definition at line 83 of file datetime.cxx.
References Date::Date(), tools::Time::GetHour(), tools::Time::GetMin(), and tools::Time::GetSec().
|
inline |
Definition at line 58 of file datetime.hxx.
References Date::GetDay(), tools::Time::GetHour(), tools::Time::GetMin(), Date::GetMonth(), tools::Time::GetNanoSec(), tools::Time::GetSec(), and Date::GetYear().
void DateTime::GetWin32FileDateTime | ( | sal_uInt32 & | rLower, |
sal_uInt32 & | rUpper | ||
) | const |
Definition at line 214 of file datetime.cxx.
References Date::Date(), tools::Time::GetNSFromTime(), Date::GetYear(), and SAL_WARN_IF.
Definition at line 54 of file datetime.cxx.
|
inline |
Definition at line 65 of file datetime.hxx.
References tools::Time::IsEqualIgnoreNanoSec().
|
private |
Definition at line 98 of file datetime.cxx.
References Date::AddDays(), tools::Time::GetHour(), tools::Time::GetTime(), Date::operator--(), tools::Time::operator=(), tools::Time::SetHour(), and tools::Time::Time().
Referenced by operator+=(), and operator-=().
|
inline |
Definition at line 75 of file datetime.hxx.
DateTime & DateTime::operator+= | ( | const tools::Duration & | rDuration | ) |
Duration can be negative, so adding it will subtract its value.
Definition at line 140 of file datetime.cxx.
References Date::AddDays(), tools::Duration::GetDays(), tools::Duration::GetTime(), and operator+=().
DateTime & DateTime::operator+= | ( | const tools::Time & | rTime | ) |
Definition at line 124 of file datetime.cxx.
References NormalizeTimeRemainderAndApply().
Referenced by AddTime(), and operator+=().
DateTime & DateTime::operator-= | ( | const tools::Time & | rTime | ) |
Definition at line 132 of file datetime.cxx.
References NormalizeTimeRemainderAndApply().
bool DateTime::operator< | ( | const DateTime & | rDateTime | ) | const |
Definition at line 65 of file datetime.cxx.
References tools::Time::operator<(), and Date::operator==().
bool DateTime::operator<= | ( | const DateTime & | rDateTime | ) | const |
Definition at line 77 of file datetime.cxx.
References tools::Time::operator<=(), and Date::operator==().
DateTime & DateTime::operator= | ( | const css::util::DateTime & | rUDateTime | ) |
Definition at line 47 of file datetime.cxx.
References Date::Date(), Date::operator=(), and tools::Time::Time().
Definition at line 129 of file datetime.hxx.
References Date::operator=().
|
inline |
Definition at line 72 of file datetime.hxx.
bool DateTime::operator> | ( | const DateTime & | rDateTime | ) | const |
Definition at line 59 of file datetime.cxx.
References Date::operator==(), and tools::Time::operator>().
bool DateTime::operator>= | ( | const DateTime & | rDateTime | ) | const |
Definition at line 71 of file datetime.cxx.
References Date::operator==(), and tools::Time::operator>=().
Use Sub() if the floating point "time in days" value is to be processed.
This also takes a shortcut for whole days values (equal times), and only for times inflicted values uses an intermediary tools::Duration for conversion. Note that the resulting floating point value nevertheless in many cases is not an exact representation down to nanoseconds.
Definition at line 203 of file datetime.cxx.
References tools::Duration::GetInDays().
|
friend |
Duration can be negative, so adding it will subtract its value.
Definition at line 175 of file datetime.cxx.
|
friend |
Definition at line 161 of file datetime.cxx.
|
friend |
Definition at line 190 of file datetime.cxx.
|
friend |
Definition at line 147 of file datetime.cxx.
|
friend |
Definition at line 113 of file datetime.hxx.
|
friend |
Definition at line 168 of file datetime.cxx.
|
friend |
Definition at line 100 of file datetime.hxx.
|
friend |
Definition at line 154 of file datetime.cxx.
|
friend |
Use operator-() if a duration is to be remembered or processed.
Definition at line 197 of file datetime.cxx.