LibreOffice Module tools (master) 1
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
tools::Time Class Reference

#include <time.hxx>

Inheritance diagram for tools::Time:
[legend]

Public Types

enum  TimeInitSystem { SYSTEM }
 
enum  TimeInitEmpty { EMPTY }
 

Public Member Functions

 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::Timeoperator= (const tools::Time &rTime)
 
Time operator- () const
 
tools::Timeoperator+= (const tools::Time &rTime)
 
tools::Timeoperator-= (const tools::Time &rTime)
 

Static Public Member Functions

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...
 

Static Public Attributes

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
 

Private Member Functions

void init (sal_uInt32 nHour, sal_uInt32 nMin, sal_uInt32 nSec, sal_uInt64 nNanoSec)
 

Private Attributes

sal_Int64 nTime
 

Friends

TOOLS_DLLPUBLIC friend Time operator+ (const tools::Time &rTime1, const tools::Time &rTime2)
 
TOOLS_DLLPUBLIC friend Time operator- (const tools::Time &rTime1, const tools::Time &rTime2)
 

Detailed Description

Definition at line 35 of file time.hxx.

Member Enumeration Documentation

◆ TimeInitEmpty

Enumerator
EMPTY 

Definition at line 49 of file time.hxx.

◆ TimeInitSystem

Enumerator
SYSTEM 

Definition at line 43 of file time.hxx.

Constructor & Destructor Documentation

◆ Time() [1/7]

tools::Time::Time ( TimeInitEmpty  )
inlineexplicit

Definition at line 67 of file time.hxx.

Referenced by DateTime::NormalizeTimeRemainderAndApply(), and DateTime::operator=().

◆ Time() [2/7]

tools::Time::Time ( TimeInitSystem  )
explicit

Definition at line 94 of file ttime.cxx.

References GetSystemDateTime(), and nTime.

◆ Time() [3/7]

tools::Time::Time ( sal_Int64  _nTime)
inlineexplicit

Definition at line 70 of file time.hxx.

References nTime.

◆ Time() [4/7]

tools::Time::Time ( const tools::Time rTime)

Definition at line 100 of file ttime.cxx.

References nTime.

◆ Time() [5/7]

tools::Time::Time ( const css::util::Time &  rTime)

Definition at line 109 of file ttime.cxx.

References init().

◆ Time() [6/7]

tools::Time::Time ( const css::util::DateTime &  rDateTime)
explicit

Definition at line 113 of file ttime.cxx.

References init().

◆ Time() [7/7]

tools::Time::Time ( sal_uInt32  nHour,
sal_uInt32  nMin,
sal_uInt32  nSec = 0,
sal_uInt64  nNanoSec = 0 
)

Definition at line 105 of file ttime.cxx.

References init().

Member Function Documentation

◆ GetClock()

void tools::Time::GetClock ( double  fTimeInDays,
sal_uInt16 &  nHour,
sal_uInt16 &  nMinute,
sal_uInt16 &  nSecond,
double &  fFractionOfSecond,
int  nFractionDecimals 
)
static

Get the wall clock time particles for a (date+)time value.

Does the necessary rounding and truncating to obtain hour, minute, second and fraction of second from a double time value (time in days, 0.5 == 12h) such that individual values are not rounded up, i.e. x:59:59.999 does not yield x+1:0:0.00

A potential date component (fTimeInDays >= 1.0) is discarded.

Parameters
nFractionDecimalsIf > 0 fFractionOfSecond is truncated to that amount of decimals. Else fFractionOfSecond returns the full remainder of the fractional second.

Definition at line 286 of file ttime.cxx.

References secondPerDay, secondPerHour, and secondPerMinute.

◆ GetHour()

sal_uInt16 tools::Time::GetHour ( ) const
inline

◆ GetMin()

sal_uInt16 tools::Time::GetMin ( ) const
inline

◆ GetMonotonicTicks()

sal_uInt64 tools::Time::GetMonotonicTicks ( )
static

Elapsed time in microseconds (1e-6) since some unspecified starting point.

Uses the high-precision, monotonic time sources provided by the OS, if available. Don't try to relate it to the system time, and also it's long time accuracy is not the best.

Currently used to measure the runtime of OpenCL shaders and to set a message creation timestamp to allow filtering of invalid timer messages.

Returns
current system ticks in microseconds (1e-6s)

Definition at line 466 of file ttime.cxx.

Referenced by GetSystemTicks().

◆ GetMSFromTime()

sal_Int32 tools::Time::GetMSFromTime ( ) const

Definition at line 243 of file ttime.cxx.

◆ GetNanoSec()

sal_uInt32 tools::Time::GetNanoSec ( ) const
inline

◆ GetNSFromTime()

sal_Int64 tools::Time::GetNSFromTime ( ) const

◆ GetSec()

sal_uInt16 tools::Time::GetSec ( ) const
inline

◆ GetSystemTicks()

sal_uInt64 tools::Time::GetSystemTicks ( )
static

Elapsed time in milliseconds (1e-3) since some unspecified starting point.

Convenience function, which just calls GetMonotonicTicks() / 1000.

Definition at line 451 of file ttime.cxx.

References GetMonotonicTicks().

Referenced by GetUTCOffset().

◆ GetTime()

sal_Int64 tools::Time::GetTime ( ) const
inline

◆ GetTimeInDays()

double tools::Time::GetTimeInDays ( ) const

12 hours == 0.5 days

Definition at line 274 of file ttime.cxx.

◆ GetUNOTime()

css::util::Time tools::Time::GetUNOTime ( ) const
inline

Definition at line 79 of file time.hxx.

◆ GetUTCOffset()

Time tools::Time::GetUTCOffset ( )
static

Definition at line 396 of file ttime.cxx.

References abs(), GetSystemTicks(), and tm.

Referenced by DateTime::ConvertToLocalTime(), and DateTime::ConvertToUTC().

◆ init()

void tools::Time::init ( sal_uInt32  nHour,
sal_uInt32  nMin,
sal_uInt32  nSec,
sal_uInt64  nNanoSec 
)
private

Definition at line 118 of file ttime.cxx.

References HOUR_MASK, MIN_MASK, SAL_MAX_UINT16, and SEC_MASK.

Referenced by Time().

◆ IsEqualIgnoreNanoSec()

bool tools::Time::IsEqualIgnoreNanoSec ( const tools::Time rTime) const

Definition at line 389 of file ttime.cxx.

References GetNanoSec(), n1, n2, and nTime.

Referenced by DateTime::IsEqualIgnoreNanoSec().

◆ MakeTimeFromMS()

void tools::Time::MakeTimeFromMS ( sal_Int32  nMS)

Definition at line 258 of file ttime.cxx.

References GetTime().

◆ MakeTimeFromNS()

void tools::Time::MakeTimeFromNS ( sal_Int64  nNS)

Definition at line 227 of file ttime.cxx.

References GetTime().

Referenced by tools::Duration::ApplyTime(), and tools::Duration::Duration().

◆ operator!=()

bool tools::Time::operator!= ( const tools::Time rTime) const
inline

Definition at line 130 of file time.hxx.

References nTime.

◆ operator+=()

Time & tools::Time::operator+= ( const tools::Time rTime)

Definition at line 363 of file ttime.cxx.

References GetTime().

◆ operator-()

Time tools::Time::operator- ( void  ) const
inline

Definition at line 165 of file time.hxx.

◆ operator-=()

Time & tools::Time::operator-= ( const tools::Time rTime)

Definition at line 370 of file ttime.cxx.

References GetTime().

◆ operator<()

bool tools::Time::operator< ( const tools::Time rTime) const
inline

Definition at line 134 of file time.hxx.

References nTime.

Referenced by DateTime::operator<().

◆ operator<=()

bool tools::Time::operator<= ( const tools::Time rTime) const
inline

Definition at line 138 of file time.hxx.

References nTime.

Referenced by DateTime::operator<=().

◆ operator=()

Time & tools::Time::operator= ( const tools::Time rTime)

Definition at line 357 of file ttime.cxx.

References nTime.

Referenced by DateTime::NormalizeTimeRemainderAndApply().

◆ operator==()

bool tools::Time::operator== ( const tools::Time rTime) const
inline

Definition at line 128 of file time.hxx.

References nTime.

◆ operator>()

bool tools::Time::operator> ( const tools::Time rTime) const
inline

Definition at line 132 of file time.hxx.

References nTime.

Referenced by DateTime::operator>().

◆ operator>=()

bool tools::Time::operator>= ( const tools::Time rTime) const
inline

Definition at line 136 of file time.hxx.

References nTime.

Referenced by DateTime::operator>=().

◆ SetHour()

void tools::Time::SetHour ( sal_uInt16  nNewHour)

Definition at line 147 of file ttime.cxx.

References HOUR_MASK, MIN_MASK, and SEC_MASK.

Referenced by tools::Duration::Duration(), and DateTime::NormalizeTimeRemainderAndApply().

◆ SetMin()

void tools::Time::SetMin ( sal_uInt16  nNewMin)

Definition at line 161 of file ttime.cxx.

References HOUR_MASK, MIN_MASK, and SEC_MASK.

◆ SetNanoSec()

void tools::Time::SetNanoSec ( sal_uInt32  nNewNanoSec)

Definition at line 195 of file ttime.cxx.

References HOUR_MASK, MIN_MASK, and SEC_MASK.

◆ SetSec()

void tools::Time::SetSec ( sal_uInt16  nNewSec)

Definition at line 178 of file ttime.cxx.

References HOUR_MASK, MIN_MASK, and SEC_MASK.

◆ SetTime()

void tools::Time::SetTime ( sal_Int64  nNewTime)
inline

Definition at line 77 of file time.hxx.

Referenced by DateTime::DateTime().

Friends And Related Function Documentation

◆ operator+

TOOLS_DLLPUBLIC friend Time operator+ ( const tools::Time rTime1,
const tools::Time rTime2 
)
friend

Definition at line 377 of file ttime.cxx.

◆ operator-

TOOLS_DLLPUBLIC friend Time operator- ( const tools::Time rTime1,
const tools::Time rTime2 
)
friend

Definition at line 383 of file ttime.cxx.

Member Data Documentation

◆ hourPerDay

const sal_Int64 tools::Time::hourPerDay = 24
static

Definition at line 53 of file time.hxx.

Referenced by tools::Duration::Mult(), and tools::Duration::Normalize().

◆ minutePerDay

const sal_Int64 tools::Time::minutePerDay = minutePerHour * hourPerDay
static

Definition at line 62 of file time.hxx.

◆ minutePerHour

const sal_Int64 tools::Time::minutePerHour = 60
static

Definition at line 54 of file time.hxx.

Referenced by tools::Duration::Mult(), and tools::Duration::Normalize().

◆ nanoPerCenti

const sal_Int64 tools::Time::nanoPerCenti = 10000000
static

Definition at line 65 of file time.hxx.

◆ nanoPerMicro

const sal_Int64 tools::Time::nanoPerMicro = 1000
static

Definition at line 63 of file time.hxx.

◆ nanoPerMilli

const sal_Int64 tools::Time::nanoPerMilli = 1000000
static

Definition at line 64 of file time.hxx.

◆ nanoSecPerDay

const sal_Int64 tools::Time::nanoSecPerDay = nanoSecPerSec * secondPerMinute * minutePerHour * hourPerDay
static

◆ nanoSecPerHour

const sal_Int64 tools::Time::nanoSecPerHour = nanoSecPerSec * secondPerMinute * minutePerHour
static

Definition at line 58 of file time.hxx.

Referenced by DateTime::CreateFromUnixTime(), and DateTime::CreateFromWin32FileDateTime().

◆ nanoSecPerMinute

const sal_Int64 tools::Time::nanoSecPerMinute = nanoSecPerSec * secondPerMinute
static

Definition at line 57 of file time.hxx.

Referenced by DateTime::CreateFromUnixTime(), and DateTime::CreateFromWin32FileDateTime().

◆ nanoSecPerSec

const sal_Int64 tools::Time::nanoSecPerSec = 1000000000
static

◆ nTime

sal_Int64 tools::Time::nTime
private

◆ secondPerDay

const sal_Int64 tools::Time::secondPerDay = secondPerMinute * minutePerHour * hourPerDay
static

Definition at line 61 of file time.hxx.

Referenced by GetClock().

◆ secondPerHour

const sal_Int64 tools::Time::secondPerHour = secondPerMinute * minutePerHour
static

Definition at line 60 of file time.hxx.

Referenced by GetClock().

◆ secondPerMinute

const sal_Int64 tools::Time::secondPerMinute = 60
static

Definition at line 55 of file time.hxx.

Referenced by GetClock(), tools::Duration::Mult(), and tools::Duration::Normalize().


The documentation for this class was generated from the following files: