Media Controller
A GStreamer implementation using the VideoXpert SDK
MediaController::Utilities Namespace Reference

Provides commonly used methods. More...

Functions

string UnixTimeToRfc3339 (unsigned int unixTime)
 Convert a unix timestamp to an RFC 3339 formatted string. More...
 
unsigned int CurrentUnixTime ()
 Get the current time as a unix timestamp. More...
 

Detailed Description

Provides commonly used methods.

Function Documentation

unsigned int MediaController::Utilities::CurrentUnixTime ( )

Get the current time as a unix timestamp.

Returns
The current time as a unix timestamp.

Definition at line 21 of file Utilities.cpp.

21  {
22  time_t currentTime;
23  time(&currentTime);
24  return static_cast<unsigned int>(currentTime);
25  }
std::string MediaController::Utilities::UnixTimeToRfc3339 ( unsigned int  unixTime)

Convert a unix timestamp to an RFC 3339 formatted string.

Parameters
unixTimeThe unix timestamp.
Returns
An RFC 3339 formatted string.

Definition at line 8 of file Utilities.cpp.

8  {
9  time_t unixTimeValue = unixTime;
10  tm tmTime;
11 #ifndef WIN32
12  gmtime_r(&unixTimeValue, &tmTime);
13 #else
14  gmtime_s(&tmTime, &unixTimeValue);
15 #endif
16  char date[Constants::kDateMaxSize];
17  strftime(date, sizeof(date), "%Y%m%dT%H%M%S.000Z-", &tmTime);
18  return string(date);
19  }
#define gmtime_s(time, result)
static const unsigned short kDateMaxSize
Definition: Constants.h:15