The qDecoder Project

qTime.c File Reference

Date and Time Handling API. More...


Functions

char * qTimeGetLocalStrf (char *buf, int size, time_t utctime, const char *format)
 Get custom formmatted local time string.
char * qTimeGetLocalStr (time_t utctime)
 Get local time string formatted like '02-Nov-2007 16:37:39 +0900'.
const char * qTimeGetLocalStaticStr (time_t utctime)
 Get local time string formatted like '02-Nov-2007 16:37:39 +0900'.
char * qTimeGetGmtStrf (char *buf, int size, time_t utctime, const char *format)
 Get custom formmatted GMT time string.
char * qTimeGetGmtStr (time_t utctime)
 Get GMT time string formatted like 'Wed, 11-Nov-2007 23:19:25 GMT'.
const char * qTimeGetGmtStaticStr (time_t utctime)
 Get GMT time string formatted like 'Wed, 11-Nov-2007 23:19:25 GMT'.
time_t qTimeParseGmtStr (const char *gmtstr)
 This parses GMT/Timezone(+/-) formatted time sting like 'Sun, 04 May 2008 18:50:39 GMT', 'Mon, 05 May 2008 03:50:39 +0900' and returns as universal time.


Detailed Description

Date and Time Handling API.


Function Documentation

char* qTimeGetLocalStrf ( char *  buf,
int  size,
time_t  utctime,
const char *  format 
)

Get custom formmatted local time string.

Parameters:
buf save buffer
size buffer size
utctime 0 for current time, universal time for specific time
format format for strftime()
Returns:
string pointer of buf
   char *timestr = qTimeGetLocalStrf(0, "%H:%M:%S"); // HH:MM:SS
   free(timestr);
   char *timestr = qTimeGetLocalStrf(0, "%Y%m%d%H%M%S"); // YYMMDDhhmmss
   free(timestr);

char* qTimeGetLocalStr ( time_t  utctime  ) 

Get local time string formatted like '02-Nov-2007 16:37:39 +0900'.

Parameters:
utctime 0 for current time, universal time for specific time
Returns:
mallocked string pointer of time string
   char *timestr;
   timestr = qGetLocaltimeStr(0);                       // now
   free(timestr);
   timestr = qGetLocaltimeStr(time(NULL));              // same as above
   free(timestr);
   timestr = qGetLocaltimeStr(time(NULL) - 86400));     // 1 day before
   free(timestr);

const char* qTimeGetLocalStaticStr ( time_t  utctime  ) 

Get local time string formatted like '02-Nov-2007 16:37:39 +0900'.

Parameters:
utctime 0 for current time, universal time for specific time
Returns:
internal static string pointer of time string
   printf("%s", qTimeGetLocalStaticStr(0));                     // now
   printf("%s", qTimeGetLocalStaticStr(time(NULL) + 86400));    // 1 day later

char* qTimeGetGmtStrf ( char *  buf,
int  size,
time_t  utctime,
const char *  format 
)

Get custom formmatted GMT time string.

Parameters:
buf save buffer
size buffer size
utctime 0 for current time, universal time for specific time
format format for strftime()
Returns:
string pointer of buf
   char timestr[8+1];
   qTimeGetGmtStrf(buf, sizeof(buf), 0, "%H:%M:%S"); // HH:MM:SS

char* qTimeGetGmtStr ( time_t  utctime  ) 

Get GMT time string formatted like 'Wed, 11-Nov-2007 23:19:25 GMT'.

Parameters:
utctime 0 for current time, universal time for specific time
Returns:
malloced string pointer which points GMT time string.
   char *timestr;
   timestr = qTimeGetGmtStr(0);                 // now
   free(timestr);
   timestr = qTimeGetGmtStr(time(NULL));                // same as above
   free(timestr);
   timestr = qTimeGetGmtStr(time(NULL) - 86400));       // 1 day before
   free(timestr);

const char* qTimeGetGmtStaticStr ( time_t  utctime  ) 

Get GMT time string formatted like 'Wed, 11-Nov-2007 23:19:25 GMT'.

Parameters:
utctime 0 for current time, universal time for specific time
Returns:
internal static string pointer which points GMT time string.
   printf("%s", qTimeGetGmtStaticStr(0));                       // now
   printf("%s", qTimeGetGmtStaticStr(time(NULL) + 86400));      // 1 day later

time_t qTimeParseGmtStr ( const char *  gmtstr  ) 

This parses GMT/Timezone(+/-) formatted time sting like 'Sun, 04 May 2008 18:50:39 GMT', 'Mon, 05 May 2008 03:50:39 +0900' and returns as universal time.

Parameters:
gmtstr GMT/Timezone(+/-) formatted time string
Returns:
universal time(UTC). in case of conversion error, returns -1.
   time_t t = time(NULL);
   char *s =  qTimeGetGmtStr(t);
   printf("%d\n", t);
   printf("%s\n", s);
   printf("%d\n", qTimeParseGmtStr(s)); // this must be same as t
   free(s);


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]