42#include "utilities/qtime.h"
51 gettimeofday(&tv, NULL);
52 long time = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
77 struct tm *localtm = localtime(&utctime);
79 if (strftime(buf, size, format, localtm) == 0) {
80 snprintf(buf, size,
"(buffer small)");
104 int size =
sizeof(char) * (CONST_STRLEN(
"00-Jan-0000 00:00:00 +0000") + 1);
105 char *timestr = (
char *) malloc(size);
126 static char timestr[
sizeof(char)
127 * (CONST_STRLEN(
"00-Jan-0000 00:00:00 +0000") + 1)];
129 "%d-%b-%Y %H:%M:%S %z");
150 utctime = time(NULL);
151 struct tm *gmtm = gmtime(&utctime);
153 strftime(buf, size, format, gmtm);
175 int size =
sizeof(char)
176 * (CONST_STRLEN(
"Mon, 00 Jan 0000 00:00:00 GMT") + 1);
177 char *timestr = (
char *) malloc(size);
181 qtime_gmt_strf(timestr, size, utctime,
"%a, %d %b %Y %H:%M:%S GMT");
198 static char timestr[
sizeof(char)
199 * (CONST_STRLEN(
"Mon, 00-Jan-0000 00:00:00 GMT") + 1)];
201 "%a, %d %b %Y %H:%M:%S GMT");
225 if (strptime(gmtstr,
"%a, %d %b %Y %H:%M:%S", &gmtm) == NULL)
227 time_t utc = timegm(&gmtm);
233 if ((p = strstr(gmtstr,
"+")) != NULL) {
234 utc -= ((atoi(p + 1) / 100) * 60 * 60);
237 }
else if ((p = strstr(gmtstr,
"-")) != NULL) {
238 utc += ((atoi(p + 1) / 100) * 60 * 60);
char * qtime_gmt_strf(char *buf, int size, time_t utctime, const char *format)
Get custom formmatted GMT time string.
char * qtime_gmt_str(time_t utctime)
Get GMT time string formatted like 'Wed, 11-Nov-2007 23:19:25 GMT'.
char * qtime_localtime_str(time_t utctime)
Get local time string formatted like '02-Nov-2007 16:37:39 +0900'.
long qtime_current_milli(void)
Returns the current time in milliseconds.
time_t qtime_parse_gmtstr(const char *gmtstr)
This parses GMT/Timezone(+/-) formatted time sting like 'Sun, 04 May 2008 18:50:39 GMT',...
char * qtime_localtime_strf(char *buf, int size, time_t utctime, const char *format)
Get custom formmatted local time string.
const char * qtime_gmt_staticstr(time_t utctime)
Get GMT time string formatted like 'Wed, 11-Nov-2007 23:19:25 GMT'.
const char * qtime_localtime_staticstr(time_t utctime)
Get local time string formatted like '02-Nov-2007 16:37:39 +0900'.