gwenhywfar 5.14.1
gwentime.h File Reference
#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/types.h>
#include <gwenhywfar/db.h>
#include <time.h>

Go to the source code of this file.

Typedefs

typedef struct GWEN_TIME GWEN_TIME

Functions

GWENHYWFAR_API GWEN_TIMEGWEN_CurrentTime (void)
GWENHYWFAR_API int GWEN_Time_AddSeconds (GWEN_TIME *ti, uint32_t secs)
GWENHYWFAR_API int GWEN_Time_Compare (const GWEN_TIME *t1, const GWEN_TIME *t0)
GWENHYWFAR_API double GWEN_Time_Diff (const GWEN_TIME *t1, const GWEN_TIME *t0)
GWENHYWFAR_API double GWEN_Time_DiffSeconds (const GWEN_TIME *t1, const GWEN_TIME *t0)
GWENHYWFAR_API GWEN_TIMEGWEN_Time_dup (const GWEN_TIME *t)
GWENHYWFAR_API void GWEN_Time_free (GWEN_TIME *t)
GWENHYWFAR_API GWEN_TIMEGWEN_Time_fromDb (GWEN_DB_NODE *db)
GWENHYWFAR_API GWEN_TIMEGWEN_Time_fromSeconds (uint32_t s)
GWENHYWFAR_API GWEN_TIMEGWEN_Time_fromString (const char *s, const char *tmpl)
GWENHYWFAR_API GWEN_TIMEGWEN_Time_fromUtcString (const char *s, const char *tmpl)
GWENHYWFAR_API int GWEN_Time_GetBrokenDownDate (const GWEN_TIME *t, int *days, int *month, int *year)
GWENHYWFAR_API int GWEN_Time_GetBrokenDownTime (const GWEN_TIME *t, int *hours, int *mins, int *secs)
GWENHYWFAR_API int GWEN_Time_GetBrokenDownUtcDate (const GWEN_TIME *t, int *days, int *month, int *year)
GWENHYWFAR_API int GWEN_Time_GetBrokenDownUtcTime (const GWEN_TIME *t, int *hours, int *mins, int *secs)
GWENHYWFAR_API double GWEN_Time_Milliseconds (const GWEN_TIME *t)
GWENHYWFAR_API GWEN_TIMEGWEN_Time_new (int year, int month, int day, int hour, int min, int sec, int inUtc)
GWENHYWFAR_API uint32_t GWEN_Time_Seconds (const GWEN_TIME *t)
GWENHYWFAR_API int GWEN_Time_SubSeconds (GWEN_TIME *ti, uint32_t secs)
GWENHYWFAR_API int GWEN_Time_toDb (const GWEN_TIME *t, GWEN_DB_NODE *db)
GWENHYWFAR_API int GWEN_Time_toString (const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)
GWENHYWFAR_API time_t GWEN_Time_toTime_t (const GWEN_TIME *t)
GWENHYWFAR_API int GWEN_Time_toUtcString (const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)

Typedef Documentation

◆ GWEN_TIME

typedef struct GWEN_TIME GWEN_TIME

Definition at line 43 of file gwentime.h.

Function Documentation

◆ GWEN_CurrentTime()

GWENHYWFAR_API GWEN_TIME * GWEN_CurrentTime ( void )

References GWENHYWFAR_API.

◆ GWEN_Time_AddSeconds()

GWENHYWFAR_API 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)

References GWENHYWFAR_API.

◆ GWEN_Time_Compare()

GWENHYWFAR_API int GWEN_Time_Compare ( const GWEN_TIME * t1,
const GWEN_TIME * t0 )

References GWENHYWFAR_API.

◆ GWEN_Time_Diff()

GWENHYWFAR_API double GWEN_Time_Diff ( const GWEN_TIME * t1,
const GWEN_TIME * t0 )

Returns the difference between t1 and t2 in milliseconds

References GWENHYWFAR_API.

◆ GWEN_Time_DiffSeconds()

GWENHYWFAR_API double GWEN_Time_DiffSeconds ( const GWEN_TIME * t1,
const GWEN_TIME * t0 )

Returns the difference between t1 and t2 in seconds

References GWENHYWFAR_API.

◆ GWEN_Time_dup()

GWENHYWFAR_API GWEN_TIME * GWEN_Time_dup ( const GWEN_TIME * t)

References GWENHYWFAR_API.

◆ GWEN_Time_free()

GWENHYWFAR_API void GWEN_Time_free ( GWEN_TIME * t)

References GWENHYWFAR_API.

◆ GWEN_Time_fromDb()

GWENHYWFAR_API GWEN_TIME * GWEN_Time_fromDb ( GWEN_DB_NODE * db)

References GWENHYWFAR_API.

◆ GWEN_Time_fromSeconds()

GWENHYWFAR_API GWEN_TIME * GWEN_Time_fromSeconds ( uint32_t s)

Creates a GWEN_TIME object from the return value of GWEN_Time_Seconds.

References GWENHYWFAR_API.

◆ GWEN_Time_fromString()

GWENHYWFAR_API 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

References GWENHYWFAR_API.

◆ GWEN_Time_fromUtcString()

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

References GWENHYWFAR_API.

◆ GWEN_Time_GetBrokenDownDate()

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

Returns the broken down date as local date.

References GWENHYWFAR_API.

◆ GWEN_Time_GetBrokenDownTime()

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

Returns the broken down time as local time.

References GWENHYWFAR_API.

◆ GWEN_Time_GetBrokenDownUtcDate()

GWENHYWFAR_API 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).

References GWENHYWFAR_API.

◆ GWEN_Time_GetBrokenDownUtcTime()

GWENHYWFAR_API 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).

References GWENHYWFAR_API.

◆ GWEN_Time_Milliseconds()

GWENHYWFAR_API double GWEN_Time_Milliseconds ( const GWEN_TIME * t)

returns the time in milliseconds

References GWENHYWFAR_API.

◆ GWEN_Time_new()

GWENHYWFAR_API 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

References GWENHYWFAR_API.

◆ GWEN_Time_Seconds()

GWENHYWFAR_API uint32_t GWEN_Time_Seconds ( const GWEN_TIME * t)

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

References GWENHYWFAR_API.

◆ GWEN_Time_SubSeconds()

GWENHYWFAR_API 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)

References GWENHYWFAR_API.

◆ GWEN_Time_toDb()

GWENHYWFAR_API int GWEN_Time_toDb ( const GWEN_TIME * t,
GWEN_DB_NODE * db )

References GWENHYWFAR_API.

◆ GWEN_Time_toString()

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

References GWENHYWFAR_API.

◆ GWEN_Time_toTime_t()

GWENHYWFAR_API time_t GWEN_Time_toTime_t ( const GWEN_TIME * t)

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

References GWENHYWFAR_API.

◆ GWEN_Time_toUtcString()

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

References GWENHYWFAR_API.