Group PJ_TIME
- group PJ_TIME
This module provides API for manipulating time.
Examples
For examples, please see:
Test: Sleep, Time, and Timestamp
Defines
-
PJ_TIME_VAL_MSEC(t)
Get the total time value in miliseconds. This is the same as multiplying the second part with 1000 and then add the miliseconds part to the result.
- Parameters
t – The time value.
- Returns
Total time in miliseconds.
-
PJ_TIME_VAL_EQ(t1, t2)
This macro will check if t1 is equal to t2.
- Parameters
t1 – The first time value to compare.
t2 – The second time value to compare.
- Returns
Non-zero if both time values are equal.
-
PJ_TIME_VAL_GT(t1, t2)
This macro will check if t1 is greater than t2
- Parameters
t1 – The first time value to compare.
t2 – The second time value to compare.
- Returns
Non-zero if t1 is greater than t2.
-
PJ_TIME_VAL_GTE(t1, t2)
This macro will check if t1 is greater than or equal to t2
- Parameters
t1 – The first time value to compare.
t2 – The second time value to compare.
- Returns
Non-zero if t1 is greater than or equal to t2.
-
PJ_TIME_VAL_LT(t1, t2)
This macro will check if t1 is less than t2
- Parameters
t1 – The first time value to compare.
t2 – The second time value to compare.
- Returns
Non-zero if t1 is less than t2.
-
PJ_TIME_VAL_LTE(t1, t2)
This macro will check if t1 is less than or equal to t2.
- Parameters
t1 – The first time value to compare.
t2 – The second time value to compare.
- Returns
Non-zero if t1 is less than or equal to t2.
-
PJ_TIME_VAL_ADD(t1, t2)
Add t2 to t1 and store the result in t1. Effectively
this macro will expand as: (t1 += t2).
- Parameters
t1 – The time value to add.
t2 – The time value to be added to t1.
-
PJ_TIME_VAL_SUB(t1, t2)
Substract t2 from t1 and store the result in t1. Effectively this macro will expand as (t1 -= t2).
- Parameters
t1 – The time value to subsctract.
t2 – The time value to be substracted from t1.
Functions
-
pj_status_t pj_gettimeofday(pj_time_val *tv)
Get current time of day in local representation.
- Parameters
tv – Variable to store the result.
- Returns
zero if successfull.
-
pj_status_t pj_time_decode(const pj_time_val *tv, pj_parsed_time *pt)
Parse time value into date/time representation.
- Parameters
tv – The time.
pt – Variable to store the date time result.
- Returns
zero if successfull.
-
pj_status_t pj_time_encode(const pj_parsed_time *pt, pj_time_val *tv)
Encode date/time to time value.
- Parameters
pt – The date/time.
tv – Variable to store time value result.
- Returns
zero if successfull.
-
pj_status_t pj_time_local_to_gmt(pj_time_val *tv)
Convert local time to GMT.
- Parameters
tv – Time to convert.
- Returns
zero if successfull.
-
pj_status_t pj_time_gmt_to_local(pj_time_val *tv)
Convert GMT to local time.
- Parameters
tv – Time to convert.
- Returns
zero if successfull.
-
void pj_time_val_normalize(pj_time_val *t)
Normalize the value in time value.
- Parameters
t – Time value to be normalized.
-
struct pj_time_val
- #include <types.h>
Representation of time value in this library. This type can be used to represent either an interval or a specific time or date.
-
struct pj_parsed_time
- #include <types.h>
This structure represent the parsed representation of time. It is acquired by calling pj_time_decode().
Public Members
-
int wday
This represents day of week where value zero means Sunday
-
int day
This represents day of month: 1-31
-
int mon
This represents month, with the value is 0 - 11 (zero is January)
-
int year
This represent the actual year (unlike in ANSI libc where the value must be added by 1900).
-
int sec
This represents the second part, with the value is 0-59
-
int min
This represents the minute part, with the value is: 0-59
-
int hour
This represents the hour part, with the value is 0-23
-
int msec
This represents the milisecond part, with the value is 0-999
-
int wday