NLMISC::CTime Class Reference

This class provide a independant local time system. More...

#include <time_nl.h>

Inherited by NLNET::_CUniTime.

List of all members.

Static Public Member Functions

static uint32 getSecondsSince1970 ()
 Return the number of second since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock.
static TTime getLocalTime ()
 Return the number of second since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock.
static TTicks getPerformanceTime ()
 Return the time in processor ticks.
static double ticksToSecond (TTicks ticks)
 Convert a ticks count into second.
static std::string getHumanRelativeTime (sint32 nbSeconds)
 Build a human readable string of a time difference in second.

Detailed Description

This class provide a independant local time system.

Author:
Vianney Lecroart, Olivier Cado
Nevrax France
Date:
2000-2005

Definition at line 55 of file time_nl.h.


Member Function Documentation

std::string NLMISC::CTime::getHumanRelativeTime ( sint32  nbSeconds  )  [static]

Build a human readable string of a time difference in second.

The result will be of the form '1 years 2 months 2 days 10 seconds'

compute the different parts

Definition at line 268 of file time_nl.cpp.

TTime NLMISC::CTime::getLocalTime (  )  [static]

Return the number of second since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock.

The time returned is UTC (aka GMT+0), ie it does not have the local time ajustement nor it have the daylight saving ajustement. This values is the same on all computer if computers are synchronized (with NTP for example). Return the local time in milliseconds. Use it only to measure time difference, the absolute value does not mean anything. On Unix, getLocalTime() will try to use the Monotonic Clock if available, otherwise the value can jump backwards if the system time is changed by a user or a NTP time sync process. The value is different on 2 different computers; use the CUniTime class to get a universal time that is the same on all computers.

Warning:
On Win32, the value is on 32 bits only. It wraps around to 0 every about 49.71 days.

The time returned is UTC (aka GMT+0), ie it does not have the local time ajustement nor it have the daylight saving ajustement. This values is the same on all computer if computers are synchronized (with NTP for example).

Definition at line 80 of file time_nl.cpp.

References nlerror.

Referenced by NL3D::CCloudScape::anim(), NL3D::CEvent3dMouseListener::CEvent3dMouseListener(), NLMISC::CFile::checkFileChange(), NLSOUND::CAudioMixerUser::curTime(), NLSOUND::CComplexSource::getTime(), NL3D::CEvent3dMouseListener::getViewMatrix(), loadForm(), loadForm2(), loadFormNoPackedSheet(), loadFormNoPackedSheet2(), NLSOUND::CComplexSource::onEvent(), NLSOUND::CComplexSource::onUpdate(), NLMISC::CCPUTimeStat::peekMeasures(), NLSOUND::CComplexSource::playStuf(), NLSOUND::CBackgroundSoundManager::setBackgroundFlags(), NLMISC::CCoTask::sleep(), ticksToSecond(), NLSOUND::CSoundDriverDSound::TimerCallback(), NLSOUND::CSoundDriverDSound::update(), NLSOUND::CAudioMixerUser::update(), and NLSOUND::CBackgroundSoundManager::updateBackgroundStatus().

TTicks NLMISC::CTime::getPerformanceTime (  )  [static]

Return the time in processor ticks.

Use it for profile purpose. If the performance time is not supported on this hardware, it returns 0.

Warning:
On a multiprocessor system, the value returned by each processor may be different. The only way to workaround this is to set a processor affinity to the measured thread.
The speed of tick increase can vary (especially on laptops or CPUs with power management), so profiling several times and computing the average could be a wise choice.

Definition at line 178 of file time_nl.cpp.

References nlwarning.

Referenced by NLMISC::CBufFIFO::front(), NLMISC::CSystemInfo::getProcessorFrequency(), NL3D::CVertexBufferHardARB::lock(), NL3D::CVertexBufferHardGLNVidia::lock(), NL3D::CVolatileVertexBuffer::lock(), NL3D::CVBDrvInfosD3D::lock(), NL3D::CVolatileIndexBuffer::lock(), NL3D::CIBDrvInfosD3D::lock(), NLMISC::NLMISC_CATEGORISED_COMMAND(), NLMISC::CIFile::open(), NLMISC::CStopWatch::pause(), NLMISC::CBufFIFO::push(), NL3D::CScene::renderPart(), NLMISC::CBufFIFO::resize(), NLMISC::CStopWatch::resume(), NLMISC::CStopWatch::start(), NLMISC::CSimpleClock::start(), NLMISC::CStopWatch::stop(), NLMISC::CSimpleClock::stop(), ticksToSecond(), and NL3D::CVertexBufferHardARB::unlock().

uint32 NLMISC::CTime::getSecondsSince1970 (  )  [static]

Return the number of second since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock.

The time returned is local, ie. it has the local time ajustement, including daylight saving if applicable. This values is the same on all computer if computers are synchronized (with NTP for example).

Definition at line 51 of file time_nl.cpp.

double NLMISC::CTime::ticksToSecond ( TTicks  ticks  )  [static]

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

Generated on Thu Jan 7 08:30:19 2010 for NeL by  doxygen 1.6.1