41 #include "qinternal.h"
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);
123 static char timestr[
sizeof(char)
124 * (CONST_STRLEN(
"00-Jan-0000 00:00:00 +0000") + 1)];
126 "%d-%b-%Y %H:%M:%S %z");
147 utctime = time(NULL);
148 struct tm *gmtm = gmtime(&utctime);
150 strftime(buf, size, format, gmtm);
172 int size =
sizeof(char)
173 * (CONST_STRLEN(
"Mon, 00 Jan 0000 00:00:00 GMT") + 1);
174 char *timestr = (
char *) malloc(size);
175 qtime_gmt_strf(timestr, size, utctime,
"%a, %d %b %Y %H:%M:%S GMT");
192 static char timestr[
sizeof(char)
193 * (CONST_STRLEN(
"Mon, 00-Jan-0000 00:00:00 GMT") + 1)];
195 "%a, %d %b %Y %H:%M:%S GMT");
219 if (strptime(gmtstr,
"%a, %d %b %Y %H:%M:%S", &gmtm) == NULL)
221 time_t utc = timegm(&gmtm);
227 if ((p = strstr(gmtstr,
"+")) != NULL) {
228 utc -= ((atoi(p + 1) / 100) * 60 * 60);
231 }
else if ((p = strstr(gmtstr,
"-")) != NULL) {
232 utc += ((atoi(p + 1) / 100) * 60 * 60);
char * qtime_localtime_strf(char *buf, int size, time_t utctime, const char *format)
Get custom formmatted local 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'.
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'.
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_gmt_strf(char *buf, int size, time_t utctime, const char *format)
Get custom formmatted GMT time string.