gwenhywfar 5.10.1
Macros | Functions
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>
Include dependency graph for gwentime_all.c:

Go to the source code of this file.

Macros

#define DISABLE_DEBUGLOG
 

Functions

GWEN_TIMEGWEN_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)
 
static 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)
 
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)
 

Macro Definition Documentation

◆ DISABLE_DEBUGLOG

#define DISABLE_DEBUGLOG

Definition at line 30 of file gwentime_all.c.

Function Documentation

◆ GWEN_CurrentTime()

GWEN_TIME * GWEN_CurrentTime ( void  )

Definition at line 62 of file gwentime_all.c.

References DBG_ERROR, GWEN_LOGDOMAIN, GWEN_NEW_OBJECT, GWEN_Time__GetCurrentTime(), and GWEN_Time_free().

Referenced by GWEN_CryptMgr_Sign(), and GWEN_DlgProgress_AddLogText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time__fillTmplChars()

void GWEN_Time__fillTmplChars ( const GWEN_TIME t,
GWEN_TIME_TMPLCHAR_LIST *  ll,
int  useUtc 
)

Definition at line 729 of file gwentime_all.c.

References DBG_ERROR, GWEN_LOGDOMAIN, GWEN_Time_GetBrokenDownDate(), GWEN_Time_GetBrokenDownTime(), GWEN_Time_GetBrokenDownUtcDate(), and GWEN_Time_GetBrokenDownUtcTime().

Referenced by GWEN_Time__toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time__findTmplChar()

GWEN_TIME_TMPLCHAR * GWEN_Time__findTmplChar ( GWEN_TIME_TMPLCHAR_LIST *  ll,
char  c 
)

Definition at line 681 of file gwentime_all.c.

Referenced by GWEN_Time__sampleTmplChars(), and GWEN_Time__toString().

Here is the caller graph for this function:

◆ GWEN_Time__fromString()

GWEN_TIME * GWEN_Time__fromString ( const char *  s,
const char *  tmpl,
int  inUtc 
)
static

Definition at line 218 of file gwentime_all.c.

References DBG_DEBUG, DBG_ERROR, DBG_INFO, DBG_VERBOUS, GWEN_LOGDOMAIN, GWEN_Time_new(), and NULL.

Referenced by GWEN_Time_fromString(), and GWEN_Time_fromUtcString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time__mktimeUtc()

uint32_t GWEN_Time__mktimeUtc ( int  year,
int  month,
int  day,
int  hour,
int  min,
int  sec 
)

Definition at line 402 of file gwentime_all.c.

Referenced by GWEN_Time_new().

Here is the caller graph for this function:

◆ GWEN_Time__sampleTmplChars()

void GWEN_Time__sampleTmplChars ( GWEN_UNUSED const GWEN_TIME t,
const char *  tmpl,
GWEN_UNUSED GWEN_BUFFER buf,
GWEN_TIME_TMPLCHAR_LIST *  ll 
)

Definition at line 699 of file gwentime_all.c.

References DBG_DEBUG, GWEN_LOGDOMAIN, GWEN_Time__findTmplChar(), and GWEN_TimeTmplChar_new().

Referenced by GWEN_Time__toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time__SetSecsAndMSecs()

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 122 of file gwentime_all.c.

◆ GWEN_Time__toString()

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

Definition at line 789 of file gwentime_all.c.

References GWEN_Buffer_AppendByte(), GWEN_Buffer_AppendString(), GWEN_Time__fillTmplChars(), GWEN_Time__findTmplChar(), and GWEN_Time__sampleTmplChars().

Referenced by GWEN_Time_toString(), and GWEN_Time_toUtcString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_AddSeconds()

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 88 of file gwentime_all.c.

References DBG_INFO, GWEN_ERROR_INVALID, and GWEN_LOGDOMAIN.

◆ GWEN_Time_Compare()

int GWEN_Time_Compare ( const GWEN_TIME t1,
const GWEN_TIME t0 
)

Definition at line 501 of file gwentime_all.c.

◆ GWEN_Time_Diff()

double GWEN_Time_Diff ( const GWEN_TIME t1,
const GWEN_TIME t0 
)

Returns the difference between t1 and t2 in milliseconds

Definition at line 471 of file gwentime_all.c.

◆ GWEN_Time_DiffSeconds()

double GWEN_Time_DiffSeconds ( const GWEN_TIME t1,
const GWEN_TIME t0 
)

Returns the difference between t1 and t2 in seconds

Definition at line 486 of file gwentime_all.c.

◆ GWEN_Time_dup()

GWEN_TIME * GWEN_Time_dup ( const GWEN_TIME t)

◆ GWEN_Time_free()

void GWEN_Time_free ( GWEN_TIME t)

◆ GWEN_Time_fromDb()

GWEN_TIME * GWEN_Time_fromDb ( GWEN_DB_NODE db)

Definition at line 174 of file gwentime_all.c.

References DBG_INFO, DBG_VERBOUS, GWEN_DB_GetGroup(), GWEN_DB_GetIntValue(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_NAMEMUSTEXIST, and GWEN_Time_new().

Referenced by GWEN_SslCertDescr_ReadDb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_fromSeconds()

GWEN_TIME * GWEN_Time_fromSeconds ( uint32_t  s)

Creates a GWEN_TIME object from the return value of GWEN_Time_Seconds.

Definition at line 77 of file gwentime_all.c.

References GWEN_NEW_OBJECT.

Referenced by GWEN_Sar_AddFile(), GWEN_SyncIo_Tls_GetPeerCert(), and GWEN_Time_new().

Here is the caller graph for this function:

◆ GWEN_Time_fromString()

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:

CharacterMeaning
Ydigit of the year
Mdigit of the month
Ddigit of the day of month
hdigit of the hour
mdigit of the minute
sdigit 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
sstring containing the date/time
tmpltemplate string

Definition at line 345 of file gwentime_all.c.

References GWEN_Time__fromString().

Referenced by _convertAndSetCharValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_fromUtcString()

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

Definition at line 352 of file gwentime_all.c.

References GWEN_Time__fromString().

Referenced by GWEN_Sar_TlvToFileHeader(), and GWEN_SigHead_fromBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_GetBrokenDownDate()

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 589 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars().

Here is the caller graph for this function:

◆ GWEN_Time_GetBrokenDownTime()

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 543 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars().

Here is the caller graph for this function:

◆ GWEN_Time_GetBrokenDownUtcDate()

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 612 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars(), and GWEN_Time_toDb().

Here is the caller graph for this function:

◆ GWEN_Time_GetBrokenDownUtcTime()

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 566 of file gwentime_all.c.

References DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Time__fillTmplChars(), and GWEN_Time_toDb().

Here is the caller graph for this function:

◆ GWEN_Time_Milliseconds()

double GWEN_Time_Milliseconds ( const GWEN_TIME t)

returns the time in milliseconds

Definition at line 527 of file gwentime_all.c.

◆ GWEN_Time_new()

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

Create a time using year, month, day, hour, min, sec.

Parameters
yearyear (e.g. 2009)
monthmonth (0-11)
dayday of month (1-31)
minminute (0-59)
secsecond (0-59)
inUtctime is given in UTC if !=0

Definition at line 359 of file gwentime_all.c.

References GWEN_Time__mktimeUtc(), and GWEN_Time_fromSeconds().

Referenced by GWEN_Time__fromString(), and GWEN_Time_fromDb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_Seconds()

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 535 of file gwentime_all.c.

◆ GWEN_Time_SubSeconds()

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 106 of file gwentime_all.c.

References DBG_INFO, GWEN_ERROR_INVALID, and GWEN_LOGDOMAIN.

◆ GWEN_Time_toDb()

int GWEN_Time_toDb ( const GWEN_TIME t,
GWEN_DB_NODE db 
)

Definition at line 133 of file gwentime_all.c.

References DBG_INFO, GWEN_DB_FLAGS_DEFAULT, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_GetGroup(), GWEN_DB_SetIntValue(), GWEN_LOGDOMAIN, GWEN_Time_GetBrokenDownUtcDate(), and GWEN_Time_GetBrokenDownUtcTime().

Referenced by GWEN_SslCertDescr_toDb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_toString()

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

Definition at line 830 of file gwentime_all.c.

References GWEN_Time__toString().

Referenced by _convertAndSetCharValue(), GWEN_Date_fromTime(), GWEN_DlgProgress_AddLogText(), and GWEN_Gui_CheckCertBuiltIn().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_Time_toTime_t()

time_t GWEN_Time_toTime_t ( const GWEN_TIME t)

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

Definition at line 650 of file gwentime_all.c.

◆ GWEN_Time_toUtcString()

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

Definition at line 838 of file gwentime_all.c.

References GWEN_Time__toString().

Referenced by GWEN_Sar_FileHeaderToTlv(), and GWEN_SigHead_toBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_TimeTmplChar_free()

void GWEN_TimeTmplChar_free ( GWEN_TIME_TMPLCHAR *  e)

Definition at line 671 of file gwentime_all.c.

References GWEN_FREE_OBJECT, and GWEN_LIST_FINI.

◆ GWEN_TimeTmplChar_new()

GWEN_TIME_TMPLCHAR * GWEN_TimeTmplChar_new ( char  c)

Definition at line 659 of file gwentime_all.c.

References GWEN_LIST_INIT, and GWEN_NEW_OBJECT.

Referenced by GWEN_Time__sampleTmplChars().

Here is the caller graph for this function: