Exemplo n.º 1
0
/*
 * cmyth_timestamp_from_unixtime(time_t l)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Create and fill out a timestamp structure using the time_t 'l'.
 *
 * Return Value:
 *
 * Success: cmyth_timestamp_t object
 *
 * Failure: -(ERRNO)
 */
cmyth_timestamp_t
cmyth_timestamp_from_unixtime(time_t l)
{
	struct tm tm_datetime;
	localtime_r(&l,&tm_datetime);
	return cmyth_timestamp_from_tm(&tm_datetime);
}
Exemplo n.º 2
0
/*
 * cmyth_timestamp_utc_from_unixtime(time_t l)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Create and fill out a UTC timestamp structure using the time_t 'l'.
 *
 * Return Value:
 *
 * Success: cmyth_timestamp_t structure
 *
 * Failure: NULL
 */
cmyth_timestamp_t
cmyth_timestamp_utc_from_unixtime(time_t l)
{
	struct tm tm_datetime;
	cmyth_timestamp_t ts;
	gmtime_r(&l, &tm_datetime);
	ts = cmyth_timestamp_from_tm(&tm_datetime);
	ts->timestamp_isutc = 1;
	return ts;
}
Exemplo n.º 3
0
/*
 * cmyth_timestamp_to_utc(cmyth_timestamp_t ts)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Create and fill out a UTC timestamp structure
 *
 * Return Value:
 *
 * Success: cmyth_timestamp_t structure
 *
 * Failure: NULL
 */
cmyth_timestamp_t
cmyth_timestamp_to_utc(cmyth_timestamp_t ts)
{
	time_t l;
	struct tm tm_datetime;
	cmyth_timestamp_t ret;

	if (!ts) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: NULL timestamp\n",
			  __FUNCTION__);
		return NULL;
	}
	if (ts->timestamp_isutc) {
		cmyth_dbg(CMYTH_DBG_ERROR, "%s: UTC timestamp provided\n",
			  __FUNCTION__);
		return NULL;
	}
	l = cmyth_timestamp_to_unixtime(ts);
	gmtime_r(&l, &tm_datetime);
	ret = cmyth_timestamp_from_tm(&tm_datetime);
	ret->timestamp_isutc = 1;
	return ret;
}