gwentime_all.c File Reference

#include "gwentime_p.h"
#include <gwenhywfar/gwentime.h>
#include <gwenhywfar/debug.h>
#include <time.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>

Go to the source code of this file.

Defines

#define DISABLE_DEBUGLOG

Functions

GWEN_TIMEGWEN_CurrentTime ()
void GWEN_Time__fillTmplChars (const GWEN_TIME *t, GWEN_TIME_TMPLCHAR_LIST *ll, int useUtc)
GWEN_TIME_TMPLCHAR * GWEN_Time__findTmplChar (GWEN_TIME_TMPLCHAR_LIST *ll, char c)
GWEN_TIMEGWEN_Time__fromString (const char *s, const char *tmpl, int inUtc)
uint32_t GWEN_Time__mktimeUtc (int year, int month, int day, int hour, int min, int sec)
void GWEN_Time__sampleTmplChars (GWEN_UNUSED const GWEN_TIME *t, const char *tmpl, GWEN_UNUSED GWEN_BUFFER *buf, GWEN_TIME_TMPLCHAR_LIST *ll)
void GWEN_Time__SetSecsAndMSecs (GWEN_TIME *ti, uint32_t secs, uint32_t msecs)
int GWEN_Time__toString (const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf, int useUtc)
int GWEN_Time_AddSeconds (GWEN_TIME *ti, uint32_t secs)
int GWEN_Time_Compare (const GWEN_TIME *t1, const GWEN_TIME *t0)
double GWEN_Time_Diff (const GWEN_TIME *t1, const GWEN_TIME *t0)
double GWEN_Time_DiffSeconds (const GWEN_TIME *t1, const GWEN_TIME *t0)
GWEN_TIMEGWEN_Time_dup (const GWEN_TIME *t)
void GWEN_Time_free (GWEN_TIME *t)
GWEN_TIMEGWEN_Time_fromDb (GWEN_DB_NODE *db)
GWEN_TIMEGWEN_Time_fromSeconds (uint32_t secs)
GWEN_TIMEGWEN_Time_fromString (const char *s, const char *tmpl)
GWEN_TIMEGWEN_Time_fromUtcString (const char *s, const char *tmpl)
int GWEN_Time_GetBrokenDownDate (const GWEN_TIME *t, int *days, int *month, int *year)
int GWEN_Time_GetBrokenDownTime (const GWEN_TIME *t, int *hours, int *mins, int *secs)
int GWEN_Time_GetBrokenDownUtcDate (const GWEN_TIME *t, int *days, int *month, int *year)
int GWEN_Time_GetBrokenDownUtcTime (const GWEN_TIME *t, int *hours, int *mins, int *secs)
double GWEN_Time_Milliseconds (const GWEN_TIME *t)
GWEN_TIMEGWEN_Time_new (int year, int month, int day, int hour, int min, int sec, int inUtc)
uint32_t GWEN_Time_Seconds (const GWEN_TIME *t)
int GWEN_Time_SubSeconds (GWEN_TIME *ti, uint32_t secs)
int GWEN_Time_toDb (const GWEN_TIME *t, GWEN_DB_NODE *db)
int GWEN_Time_toString (const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)
time_t GWEN_Time_toTime_t (const GWEN_TIME *t)
struct tm GWEN_Time_toTm (const GWEN_TIME *t)
int GWEN_Time_toUtcString (const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)
void GWEN_TimeTmplChar_free (GWEN_TIME_TMPLCHAR *e)
GWEN_TIME_TMPLCHAR * GWEN_TimeTmplChar_new (char c)

Define Documentation

#define DISABLE_DEBUGLOG

Definition at line 33 of file gwentime_all.c.


Function Documentation

GWEN_TIME* GWEN_CurrentTime ( void   ) 
void GWEN_Time__fillTmplChars ( const GWEN_TIME t,
GWEN_TIME_TMPLCHAR_LIST *  ll,
int  useUtc 
)
GWEN_TIME_TMPLCHAR* GWEN_Time__findTmplChar ( GWEN_TIME_TMPLCHAR_LIST *  ll,
char  c 
)

Definition at line 638 of file gwentime_all.c.

Referenced by GWEN_Time__sampleTmplChars(), and GWEN_Time__toString().

GWEN_TIME* GWEN_Time__fromString ( const char *  s,
const char *  tmpl,
int  inUtc 
)
uint32_t GWEN_Time__mktimeUtc ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec 
)

Definition at line 377 of file gwentime_all.c.

Referenced by GWEN_Time_new().

void GWEN_Time__sampleTmplChars ( GWEN_UNUSED const GWEN_TIME t,
const char *  tmpl,
GWEN_UNUSED GWEN_BUFFER buf,
GWEN_TIME_TMPLCHAR_LIST *  ll 
)
void GWEN_Time__SetSecsAndMSecs ( GWEN_TIME ti,
uint32_t  secs,
uint32_t  msecs 
)

This function is called by OS dependant implementations of GWEN_Time__GetCurrentTime.

Definition at line 106 of file gwentime_all.c.

int GWEN_Time__toString ( const GWEN_TIME t,
const char *  tmpl,
GWEN_BUFFER buf,
int  useUtc 
)
int GWEN_Time_AddSeconds ( GWEN_TIME ti,
uint32_t  secs 
)

Adds the given number of seconds to the given GWEN_TIME.

Returns:
0 if ok, !=0 on error (see Simplified Error Codes)

Definition at line 74 of file gwentime_all.c.

References DBG_INFO, GWEN_ERROR_INVALID, and GWEN_LOGDOMAIN.

int GWEN_Time_Compare ( const GWEN_TIME t1,
const GWEN_TIME t0 
)

Definition at line 472 of file gwentime_all.c.

double GWEN_Time_Diff ( const GWEN_TIME t1,
const GWEN_TIME t0 
)

Returns the difference between t1 and t2 in milliseconds

Definition at line 444 of file gwentime_all.c.

Referenced by GWEN_Io_Manager_WaitForRequest().

double GWEN_Time_DiffSeconds ( const GWEN_TIME t1,
const GWEN_TIME t0 
)

Returns the difference between t1 and t2 in seconds

Definition at line 458 of file gwentime_all.c.

GWEN_TIME* GWEN_Time_dup ( const GWEN_TIME t  ) 
void GWEN_Time_free ( GWEN_TIME t  ) 
GWEN_TIME* GWEN_Time_fromDb ( GWEN_DB_NODE db  ) 
GWEN_TIME* GWEN_Time_fromSeconds ( uint32_t  s  ) 

Creates a GWEN_TIME object from the return value of GWEN_Time_Seconds.

Definition at line 64 of file gwentime_all.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_Io_LayerTls_GetPeerCert(), and GWEN_Time_new().

GWEN_TIME* GWEN_Time_fromString ( const char *  s,
const char *  tmpl 
)

Parses the data and time from the given string according to the template string (quite similar to sscanf).

The string is expected to contain the date/time in local time. The following characters are accepted in the template string:

Character

Meaning

Y

digit of the year

M

digit of the month

D

digit of the day of month

h

digit of the hour

m

digit of the minute

s

digit of the second

All other characters are ignored.
Some examples of valid patterns follow:

  • "YYYYMMDD"
  • "YYMMDD"
  • "YY/MM/DD"
  • "YYYYMMDD hh:mm:ss"
  • "YYYYMMDD hh:mm"
  • "YYYYMMDD hhmmss"
  • et cetera
Returns:
0 on error, a GWEN_TIME pointer otherwise
Parameters:
s string containing the date/time
tmpl template string

Definition at line 323 of file gwentime_all.c.

References GWEN_Time__fromString().

GWEN_TIME* GWEN_Time_fromUtcString ( const char *  s,
const char *  tmpl 
)

Definition at line 329 of file gwentime_all.c.

References GWEN_Time__fromString().

Referenced by GWEN_SigHead_fromBuffer().

int GWEN_Time_GetBrokenDownDate ( const GWEN_TIME t,
int *  days,
int *  month,
int *  year 
)

Returns the broken down date as local date.

Definition at line 555 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars().

int GWEN_Time_GetBrokenDownTime ( const GWEN_TIME t,
int *  hours,
int *  mins,
int *  secs 
)

Returns the broken down time as local time.

Definition at line 511 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars().

int GWEN_Time_GetBrokenDownUtcDate ( const GWEN_TIME t,
int *  days,
int *  month,
int *  year 
)

Returns the broken down time as UTC date (Greenwhich Mean time).

Definition at line 577 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars(), and GWEN_Time_toDb().

int GWEN_Time_GetBrokenDownUtcTime ( const GWEN_TIME t,
int *  hours,
int *  mins,
int *  secs 
)

Returns the broken down time as UTC time (Greenwhich Mean time).

Definition at line 533 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars(), and GWEN_Time_toDb().

double GWEN_Time_Milliseconds ( const GWEN_TIME t  ) 

returns the time in milliseconds

Definition at line 497 of file gwentime_all.c.

GWEN_TIME* GWEN_Time_new ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec,
int  inUtc 
)

Definition at line 335 of file gwentime_all.c.

References GWEN_Time__mktimeUtc(), and GWEN_Time_fromSeconds().

Referenced by GWEN_Time__fromString(), and GWEN_Time_fromDb().

uint32_t GWEN_Time_Seconds ( const GWEN_TIME t  ) 

Returns the time in seconds since the epoch (00:00:00 UTC Jan 1, 1970).

Definition at line 504 of file gwentime_all.c.

int GWEN_Time_SubSeconds ( GWEN_TIME ti,
uint32_t  secs 
)

Subs the given number of seconds from the given GWEN_TIME.

Returns:
0 if ok, !=0 on error (see Simplified Error Codes)

Definition at line 91 of file gwentime_all.c.

References DBG_INFO, GWEN_ERROR_INVALID, and GWEN_LOGDOMAIN.

int GWEN_Time_toDb ( const GWEN_TIME t,
GWEN_DB_NODE db 
)
int GWEN_Time_toString ( const GWEN_TIME t,
const char *  tmpl,
GWEN_BUFFER buf 
)

Definition at line 761 of file gwentime_all.c.

References GWEN_Time__toString().

Referenced by GWEN_Gui_CheckCertBuiltIn().

time_t GWEN_Time_toTime_t ( const GWEN_TIME t  ) 

Returns this date as a time_t value (see time(2)).

Definition at line 610 of file gwentime_all.c.

struct tm GWEN_Time_toTm ( const GWEN_TIME t  )  [read]

Returns this date as a struct tm (see ctime(3)) in the local time zone.

Definition at line 600 of file gwentime_all.c.

int GWEN_Time_toUtcString ( const GWEN_TIME t,
const char *  tmpl,
GWEN_BUFFER buf 
)

Definition at line 768 of file gwentime_all.c.

References GWEN_Time__toString().

Referenced by GWEN_SigHead_toBuffer().

void GWEN_TimeTmplChar_free ( GWEN_TIME_TMPLCHAR *  e  ) 

Definition at line 629 of file gwentime_all.c.

References GWEN_FREE_OBJECT, and GWEN_LIST_FINI.

GWEN_TIME_TMPLCHAR* GWEN_TimeTmplChar_new ( char  c  ) 

Definition at line 618 of file gwentime_all.c.

References GWEN_LIST_INIT, and GWEN_NEW_OBJECT.

Referenced by GWEN_Time__sampleTmplChars().


Generated on Sat Jan 2 09:32:37 2010 for gwenhywfar by  doxygen 1.6.1