void glk_simple_time_to_date_local(glsi32 time, glui32 factor, glkdate_t *date) { time_t timestamp = (time_t)time * factor; struct tm tm; localtime_r(×tamp, &tm); gli_date_from_tm(date, &tm); date->microsec = 0; }
/** * glk_simple_time_to_date_local: * @time: Timestamp as returned by glk_current_simple_time(). * @factor: Factor by which to multiply @time in order to get seconds. * @date: An empty #glkdate_t structure to fill in. * * Does the same thing as glk_simple_time_to_date_utc(), but fills in the @date * structure in local time. */ void glk_simple_time_to_date_local(glsi32 time, glui32 factor, glkdate_t *date) { g_return_if_fail(factor != 0); g_return_if_fail(date != NULL); time_t timestamp = (time_t)time * factor; struct tm tm; localtime_r(×tamp, &tm); gli_date_from_tm(date, &tm); date->microsec = 0; }
void glk_time_to_date_local(glktimeval_t *time, glkdate_t *date) { time_t timestamp; struct tm tm; timestamp = time->low_sec; if (sizeof(timestamp) > 4) { timestamp += ((int64_t)time->high_sec << 32); } localtime_r(×tamp, &tm); gli_date_from_tm(date, &tm); date->microsec = time->microsec; }
/** * glk_time_to_date_utc: * @time: A #glktimeval_t structure as returned by glk_current_time(). * @date: An empty #glkdate_t structure to fill in. * * Convert the given timestamp (as returned by glk_current_time()) to a * broken-out structure. This function returns a date and time in universal time * (GMT). * * <note><para> * The seconds value may be 60 because of a leap second. * </para></note> */ void glk_time_to_date_utc(glktimeval_t *time, glkdate_t *date) { g_return_if_fail(time != NULL); g_return_if_fail(date != NULL); time_t timestamp; struct tm tm; timestamp = time->low_sec; if (sizeof(timestamp) > 4) { timestamp += ((gint64)time->high_sec << 32); } gmtime_r(×tamp, &tm); gli_date_from_tm(date, &tm); date->microsec = time->microsec; }