A time holding class.
More...
#include <yateclass.h>
|
static void | toTimeval (struct timeval *tv, u_int64_t usec) |
|
static u_int64_t | fromTimeval (const struct timeval *tv) |
|
static u_int64_t | fromTimeval (const struct timeval &tv) |
|
static u_int64_t | now () |
|
static u_int64_t | msecNow () |
|
static u_int32_t | secNow () |
|
static unsigned int | toEpoch (int year, unsigned int month, unsigned int day, unsigned int hour, unsigned int minute, unsigned int sec, int offset=0) |
|
static bool | toDateTime (unsigned int epochTimeSec, int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &sec, unsigned int *wDay=0) |
|
static bool | isLeap (unsigned int year) |
|
static int | timeZone () |
|
A time holding class.
The Time class holds a time moment with microsecond accuracy
Constructs a Time object from the current time
Constructs a Time object from a given time
- Parameters
-
Time |
( |
const struct timeval * |
tv | ) |
|
|
inlineexplicit |
Constructs a Time object from a timeval structure pointer
- Parameters
-
tv | Pointer to the timeval structure |
Time |
( |
const struct timeval & |
tv | ) |
|
|
inlineexplicit |
Constructs a Time object from a timeval structure
- Parameters
-
tv | Reference of the timeval structure |
Do-nothing destructor that keeps the compiler from complaining about inlining derivates or members of Time type
static u_int64_t fromTimeval |
( |
const struct timeval * |
tv | ) |
|
|
static |
Convert time in a timeval struct to microseconds
- Parameters
-
tv | Pointer to the timeval structure |
- Returns
- Corresponding time in microseconds or zero if tv is NULL
Referenced by Time::fromTimeval().
static u_int64_t fromTimeval |
( |
const struct timeval & |
tv | ) |
|
|
inlinestatic |
Convert time in a timeval struct to microseconds
- Parameters
-
tv | Reference of the timeval structure |
- Returns
- Corresponding time in microseconds
References Time::fromTimeval().
static bool isLeap |
( |
unsigned int |
year | ) |
|
|
inlinestatic |
Check if an year is a leap one
- Parameters
-
- Returns
- True if the given year is a leap one
Get time in milliseconds
- Returns
- Time in milliseconds since the Epoch
static u_int64_t msecNow |
( |
| ) |
|
|
static |
Get the current system time in milliseconds
- Returns
- Time in milliseconds since the Epoch
Get the current system time in microseconds
- Returns
- Time in microseconds since the Epoch
operator u_int64_t |
( |
| ) |
const |
|
inline |
Conversion to microseconds operator
Time& operator+= |
( |
int64_t |
delta | ) |
|
|
inline |
Time& operator-= |
( |
int64_t |
delta | ) |
|
|
inline |
Time& operator= |
( |
u_int64_t |
usec | ) |
|
|
inline |
Get time in seconds
- Returns
- Time in seconds since the Epoch
static u_int32_t secNow |
( |
| ) |
|
|
static |
Get the current system time in seconds
- Returns
- Time in seconds since the Epoch
Retrieve the difference between local time and UTC in seconds east of UTC
- Returns
- Difference between local time and UTC in seconds
static bool toDateTime |
( |
unsigned int |
epochTimeSec, |
|
|
int & |
year, |
|
|
unsigned int & |
month, |
|
|
unsigned int & |
day, |
|
|
unsigned int & |
hour, |
|
|
unsigned int & |
minute, |
|
|
unsigned int & |
sec, |
|
|
unsigned int * |
wDay = 0 |
|
) |
| |
|
static |
Split a given EPOCH time into its date/time components
- Parameters
-
epochTimeSec | EPOCH time in seconds |
year | The year component of the date |
month | The month component of the date (1 to 12) |
day | The day component of the date (1 to 31) |
hour | The hour component of the time (0 to 23) |
minute | The minute component of the time (0 to 59) |
sec | The seconds component of the time (0 to 59) |
wDay | The day of the week (optional) |
- Returns
- True on succes, false if conversion failed
static unsigned int toEpoch |
( |
int |
year, |
|
|
unsigned int |
month, |
|
|
unsigned int |
day, |
|
|
unsigned int |
hour, |
|
|
unsigned int |
minute, |
|
|
unsigned int |
sec, |
|
|
int |
offset = 0 |
|
) |
| |
|
static |
Build EPOCH time from date/time components
- Parameters
-
year | The year component of the date. Must be greater then 1969 |
month | The month component of the date (1 to 12) |
day | The day component of the date (1 to 31) |
hour | The hour component of the time (0 to 23). The hour can be 24 if minute and sec are 0 |
minute | The minute component of the time (0 to 59) |
sec | The seconds component of the time (0 to 59) |
offset | Optional number of seconds to be added/substracted to/from result. It can't exceed the number of seconds in a day |
- Returns
- EPOCH time in seconds, -1 on failure
void toTimeval |
( |
struct timeval * |
tv | ) |
const |
|
inline |
Fill in a timeval struct from a value in microseconds
- Parameters
-
tv | Pointer to the timeval structure |
static void toTimeval |
( |
struct timeval * |
tv, |
|
|
u_int64_t |
usec |
|
) |
| |
|
static |
Fill in a timeval struct from a value in microseconds
- Parameters
-
tv | Pointer to the timeval structure |
usec | Time to convert to timeval |
The documentation for this class was generated from the following file: