gwenhywfar 5.10.1
Functions | Variables
gwendate.c File Reference
#include "gwendate_p.h"
#include "i18n_l.h"
#include <gwenhywfar/debug.h>
#include <gwenhywfar/misc.h>
#include <time.h>
#include <ctype.h>
Include dependency graph for gwendate.c:

Go to the source code of this file.

Functions

static GWEN_DATE_createFromGregorianAndUseGivenString (int y, int m, int d, const char *s)
 
static int _daysInMonth (int month, int year)
 
static void _writeAsString (GWEN_DATE *gd)
 
void GWEN_Date__fillTmplChars (const GWEN_DATE *t, GWEN_DATE_TMPLCHAR_LIST *ll)
 
GWEN_DATE_TMPLCHAR * GWEN_Date__findTmplChar (GWEN_DATE_TMPLCHAR_LIST *ll, char c)
 
void GWEN_Date__sampleTmplChars (GWEN_UNUSED const GWEN_DATE *t, const char *tmpl, GWEN_UNUSED GWEN_BUFFER *buf, GWEN_DATE_TMPLCHAR_LIST *ll)
 
void GWEN_Date_AddDays (GWEN_DATE *gd, int days)
 
int GWEN_Date_Compare (const GWEN_DATE *gd1, const GWEN_DATE *gd0)
 
GWEN_DATEGWEN_Date_CurrentDate (void)
 
int GWEN_Date_DaysInMonth (const GWEN_DATE *gd)
 
int GWEN_Date_DaysInYear (const GWEN_DATE *gd)
 
int GWEN_Date_Diff (const GWEN_DATE *gd1, const GWEN_DATE *gd0)
 
GWEN_DATEGWEN_Date_dup (const GWEN_DATE *ogd)
 
void GWEN_Date_free (GWEN_DATE *gd)
 
GWEN_DATEGWEN_Date_fromDb (GWEN_DB_NODE *db)
 
GWEN_DATEGWEN_Date_fromGmTime (time_t t)
 
GWEN_DATEGWEN_Date_fromGregorian (int y, int m, int d)
 
GWEN_DATEGWEN_Date_fromJulian (int julian)
 
GWEN_DATEGWEN_Date_fromLocalTime (time_t t)
 
GWEN_DATEGWEN_Date_fromString (const char *s)
 
GWEN_DATEGWEN_Date_fromStringWithTemplate (const char *s, const char *tmpl)
 
GWEN_DATEGWEN_Date_fromTime (const GWEN_TIME *ti)
 
int GWEN_Date_GetDay (const GWEN_DATE *gd)
 
int GWEN_Date_GetJulian (const GWEN_DATE *gd)
 
GWEN_DATEGWEN_Date_GetLastHalfYearEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastHalfYearStart (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastMonthEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastMonthStart (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastQuarterYearEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastQuarterYearStart (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastYearEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetLastYearStart (const GWEN_DATE *dt)
 
int GWEN_Date_GetMonth (const GWEN_DATE *gd)
 
const char * GWEN_Date_GetString (const GWEN_DATE *gd)
 
GWEN_DATEGWEN_Date_GetThisHalfYearEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisHalfYearStart (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisMonthEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisMonthStart (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisQuarterYearEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisQuarterYearStart (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisYearEnd (const GWEN_DATE *dt)
 
GWEN_DATEGWEN_Date_GetThisYearStart (const GWEN_DATE *dt)
 
int GWEN_Date_GetYear (const GWEN_DATE *gd)
 
int GWEN_Date_IsLeapYear (int y)
 
void GWEN_Date_setJulian (GWEN_DATE *gd, int julian)
 
void GWEN_Date_SubDays (GWEN_DATE *gd, int days)
 
int GWEN_Date_toDb (const GWEN_DATE *dt, GWEN_DB_NODE *db)
 
time_t GWEN_Date_toLocalTime (const GWEN_DATE *gd)
 
int GWEN_Date_toStringWithTemplate (const GWEN_DATE *t, const char *tmpl, GWEN_BUFFER *buf)
 
int GWEN_Date_WeekDay (const GWEN_DATE *gd)
 
void GWEN_DateTmplChar_free (GWEN_DATE_TMPLCHAR *e)
 
GWEN_DATE_TMPLCHAR * GWEN_DateTmplChar_new (char c)
 

Variables

static const uint8_t daysInMonth [12]
 

Function Documentation

◆ _createFromGregorianAndUseGivenString()

GWEN_DATE * _createFromGregorianAndUseGivenString ( int  y,
int  m,
int  d,
const char *  s 
)
static

Definition at line 63 of file gwendate.c.

References _daysInMonth(), _writeAsString(), DBG_INFO, GWEN_LOGDOMAIN, GWEN_NEW_OBJECT, and NULL.

Referenced by GWEN_Date_fromGregorian(), and GWEN_Date_fromString().

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

◆ _daysInMonth()

int _daysInMonth ( int  month,
int  year 
)
static

Definition at line 354 of file gwendate.c.

References daysInMonth, DBG_INFO, GWEN_Date_IsLeapYear(), GWEN_ERROR_GENERIC, and GWEN_LOGDOMAIN.

Referenced by _createFromGregorianAndUseGivenString(), and GWEN_Date_DaysInMonth().

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

◆ _writeAsString()

void _writeAsString ( GWEN_DATE gd)
static

Definition at line 131 of file gwendate.c.

Referenced by _createFromGregorianAndUseGivenString(), and GWEN_Date_setJulian().

Here is the caller graph for this function:

◆ GWEN_Date__fillTmplChars()

void GWEN_Date__fillTmplChars ( const GWEN_DATE t,
GWEN_DATE_TMPLCHAR_LIST *  ll 
)

Definition at line 672 of file gwendate.c.

References DBG_DEBUG, DBG_ERROR, GWEN_Date_WeekDay(), GWEN_LOGDOMAIN, I18N, and NULL.

Referenced by GWEN_Date_toStringWithTemplate().

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

◆ GWEN_Date__findTmplChar()

GWEN_DATE_TMPLCHAR * GWEN_Date__findTmplChar ( GWEN_DATE_TMPLCHAR_LIST *  ll,
char  c 
)

Definition at line 625 of file gwendate.c.

Referenced by GWEN_Date__sampleTmplChars(), and GWEN_Date_toStringWithTemplate().

Here is the caller graph for this function:

◆ GWEN_Date__sampleTmplChars()

void GWEN_Date__sampleTmplChars ( GWEN_UNUSED const GWEN_DATE t,
const char *  tmpl,
GWEN_UNUSED GWEN_BUFFER buf,
GWEN_DATE_TMPLCHAR_LIST *  ll 
)

Definition at line 642 of file gwendate.c.

References DBG_DEBUG, GWEN_Date__findTmplChar(), GWEN_DateTmplChar_new(), and GWEN_LOGDOMAIN.

Referenced by GWEN_Date_toStringWithTemplate().

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

◆ GWEN_Date_AddDays()

void GWEN_Date_AddDays ( GWEN_DATE gd,
int  days 
)

Add days to the given date.

Definition at line 160 of file gwendate.c.

References GWEN_Date_setJulian().

Here is the call graph for this function:

◆ GWEN_Date_Compare()

int GWEN_Date_Compare ( const GWEN_DATE gd1,
const GWEN_DATE gd0 
)

Definition at line 433 of file gwendate.c.

Referenced by test_date().

Here is the caller graph for this function:

◆ GWEN_Date_CurrentDate()

GWEN_DATE * GWEN_Date_CurrentDate ( void  )

Create a date from the current local date.

Definition at line 245 of file gwendate.c.

References GWEN_Date_fromLocalTime().

Referenced by test_date().

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

◆ GWEN_Date_DaysInMonth()

int GWEN_Date_DaysInMonth ( const GWEN_DATE gd)

Definition at line 347 of file gwendate.c.

References _daysInMonth().

Here is the call graph for this function:

◆ GWEN_Date_DaysInYear()

int GWEN_Date_DaysInYear ( const GWEN_DATE gd)

Returns the distance between the given date and the begin of that year. E.g. if the given date is the 1st of January the result is 0.

Definition at line 369 of file gwendate.c.

References GWEN_Date_free(), and GWEN_Date_fromGregorian().

Here is the call graph for this function:

◆ GWEN_Date_Diff()

int GWEN_Date_Diff ( const GWEN_DATE gd1,
const GWEN_DATE gd0 
)

Definition at line 453 of file gwendate.c.

◆ GWEN_Date_dup()

GWEN_DATE * GWEN_Date_dup ( const GWEN_DATE ogd)

Definition at line 255 of file gwendate.c.

References GWEN_NEW_OBJECT.

◆ GWEN_Date_free()

void GWEN_Date_free ( GWEN_DATE gd)

◆ GWEN_Date_fromDb()

GWEN_DATE * GWEN_Date_fromDb ( GWEN_DB_NODE db)

Definition at line 812 of file gwendate.c.

References DBG_INFO, DBG_VERBOUS, GWEN_Date_fromString(), GWEN_DB_GetCharValue(), GWEN_LOGDOMAIN, and NULL.

Here is the call graph for this function:

◆ GWEN_Date_fromGmTime()

GWEN_DATE * GWEN_Date_fromGmTime ( time_t  t)

Definition at line 227 of file gwendate.c.

References GWEN_Date_fromGregorian(), and NULL.

Here is the call graph for this function:

◆ GWEN_Date_fromGregorian()

GWEN_DATE * GWEN_Date_fromGregorian ( int  y,
int  m,
int  d 
)

◆ GWEN_Date_fromJulian()

GWEN_DATE * GWEN_Date_fromJulian ( int  julian)

Create a date from the julian calender.

Parameters
juliandate in julian calender

Definition at line 174 of file gwendate.c.

References GWEN_Date_setJulian(), and GWEN_NEW_OBJECT.

Referenced by GWEN_Date_GetLastHalfYearEnd(), GWEN_Date_GetLastMonthEnd(), GWEN_Date_GetLastMonthStart(), GWEN_Date_GetLastQuarterYearEnd(), and GWEN_Date_GetLastYearEnd().

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

◆ GWEN_Date_fromLocalTime()

GWEN_DATE * GWEN_Date_fromLocalTime ( time_t  t)

Definition at line 185 of file gwendate.c.

References GWEN_Date_fromGregorian(), and NULL.

Referenced by GWEN_Date_CurrentDate(), and test_date().

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

◆ GWEN_Date_fromString()

GWEN_DATE * GWEN_Date_fromString ( const char *  s)

Definition at line 276 of file gwendate.c.

References _createFromGregorianAndUseGivenString(), DBG_INFO, GWEN_Date_fromGregorian(), GWEN_LOGDOMAIN, and NULL.

Referenced by _convertAndSetCharValue(), GWEN_Date_fromDb(), and GWEN_Date_fromTime().

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

◆ GWEN_Date_fromStringWithTemplate()

GWEN_DATE * GWEN_Date_fromStringWithTemplate ( const char *  s,
const char *  tmpl 
)

Definition at line 479 of file gwendate.c.

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

Referenced by _convertAndSetCharValue().

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

◆ GWEN_Date_fromTime()

GWEN_DATE * GWEN_Date_fromTime ( const GWEN_TIME ti)

Definition at line 463 of file gwendate.c.

References GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_Date_fromString(), and GWEN_Time_toString().

Here is the call graph for this function:

◆ GWEN_Date_GetDay()

int GWEN_Date_GetDay ( const GWEN_DATE gd)

Definition at line 401 of file gwendate.c.

◆ GWEN_Date_GetJulian()

int GWEN_Date_GetJulian ( const GWEN_DATE gd)

◆ GWEN_Date_GetLastHalfYearEnd()

GWEN_DATE * GWEN_Date_GetLastHalfYearEnd ( const GWEN_DATE dt)

Definition at line 1032 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_fromJulian(), GWEN_Date_GetJulian(), and GWEN_Date_GetThisHalfYearStart().

Referenced by GWEN_Date_GetLastHalfYearStart().

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

◆ GWEN_Date_GetLastHalfYearStart()

GWEN_DATE * GWEN_Date_GetLastHalfYearStart ( const GWEN_DATE dt)

Definition at line 1019 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_GetLastHalfYearEnd(), and GWEN_Date_GetThisHalfYearStart().

Here is the call graph for this function:

◆ GWEN_Date_GetLastMonthEnd()

GWEN_DATE * GWEN_Date_GetLastMonthEnd ( const GWEN_DATE dt)

Definition at line 980 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_fromGregorian(), GWEN_Date_fromJulian(), GWEN_Date_GetJulian(), GWEN_Date_GetMonth(), and GWEN_Date_GetYear().

Here is the call graph for this function:

◆ GWEN_Date_GetLastMonthStart()

GWEN_DATE * GWEN_Date_GetLastMonthStart ( const GWEN_DATE dt)

Definition at line 963 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_fromGregorian(), GWEN_Date_fromJulian(), GWEN_Date_GetJulian(), GWEN_Date_GetMonth(), and GWEN_Date_GetYear().

Here is the call graph for this function:

◆ GWEN_Date_GetLastQuarterYearEnd()

GWEN_DATE * GWEN_Date_GetLastQuarterYearEnd ( const GWEN_DATE dt)

Definition at line 1006 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_fromJulian(), GWEN_Date_GetJulian(), and GWEN_Date_GetThisQuarterYearStart().

Referenced by GWEN_Date_GetLastQuarterYearStart().

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

◆ GWEN_Date_GetLastQuarterYearStart()

GWEN_DATE * GWEN_Date_GetLastQuarterYearStart ( const GWEN_DATE dt)

Definition at line 993 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_GetLastQuarterYearEnd(), and GWEN_Date_GetThisQuarterYearStart().

Here is the call graph for this function:

◆ GWEN_Date_GetLastYearEnd()

GWEN_DATE * GWEN_Date_GetLastYearEnd ( const GWEN_DATE dt)

Definition at line 1058 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_fromJulian(), GWEN_Date_GetJulian(), and GWEN_Date_GetThisYearStart().

Referenced by GWEN_Date_GetLastYearStart().

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

◆ GWEN_Date_GetLastYearStart()

GWEN_DATE * GWEN_Date_GetLastYearStart ( const GWEN_DATE dt)

Definition at line 1045 of file gwendate.c.

References GWEN_Date_free(), GWEN_Date_GetLastYearEnd(), and GWEN_Date_GetThisYearStart().

Here is the call graph for this function:

◆ GWEN_Date_GetMonth()

int GWEN_Date_GetMonth ( const GWEN_DATE gd)

◆ GWEN_Date_GetString()

const char * GWEN_Date_GetString ( const GWEN_DATE gd)

Definition at line 425 of file gwendate.c.

Referenced by _convertAndSetCharValue(), GWEN_Date_toDb(), and test_date().

Here is the caller graph for this function:

◆ GWEN_Date_GetThisHalfYearEnd()

GWEN_DATE * GWEN_Date_GetThisHalfYearEnd ( const GWEN_DATE dt)

Definition at line 939 of file gwendate.c.

References GWEN_Date_fromGregorian(), GWEN_Date_GetMonth(), and GWEN_Date_GetYear().

Here is the call graph for this function:

◆ GWEN_Date_GetThisHalfYearStart()

GWEN_DATE * GWEN_Date_GetThisHalfYearStart ( const GWEN_DATE dt)

Definition at line 929 of file gwendate.c.

References GWEN_Date_fromGregorian(), GWEN_Date_GetMonth(), and GWEN_Date_GetYear().

Referenced by GWEN_Date_GetLastHalfYearEnd(), and GWEN_Date_GetLastHalfYearStart().

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

◆ GWEN_Date_GetThisMonthEnd()

GWEN_DATE * GWEN_Date_GetThisMonthEnd ( const GWEN_DATE dt)

Definition at line 843 of file gwendate.c.

References DBG_ERROR, GWEN_Date_fromGregorian(), GWEN_Date_GetMonth(), GWEN_Date_GetYear(), GWEN_Date_IsLeapYear(), and GWEN_LOGDOMAIN.

Here is the call graph for this function:

◆ GWEN_Date_GetThisMonthStart()

GWEN_DATE * GWEN_Date_GetThisMonthStart ( const GWEN_DATE dt)

Definition at line 836 of file gwendate.c.

References GWEN_Date_fromGregorian(), GWEN_Date_GetMonth(), and GWEN_Date_GetYear().

Here is the call graph for this function:

◆ GWEN_Date_GetThisQuarterYearEnd()

GWEN_DATE * GWEN_Date_GetThisQuarterYearEnd ( const GWEN_DATE dt)

Definition at line 905 of file gwendate.c.

References DBG_ERROR, GWEN_Date_fromGregorian(), GWEN_Date_GetMonth(), GWEN_Date_GetYear(), GWEN_LOGDOMAIN, and NULL.

Here is the call graph for this function:

◆ GWEN_Date_GetThisQuarterYearStart()

GWEN_DATE * GWEN_Date_GetThisQuarterYearStart ( const GWEN_DATE dt)

Definition at line 881 of file gwendate.c.

References DBG_ERROR, GWEN_Date_fromGregorian(), GWEN_Date_GetMonth(), GWEN_Date_GetYear(), GWEN_LOGDOMAIN, and NULL.

Referenced by GWEN_Date_GetLastQuarterYearEnd(), and GWEN_Date_GetLastQuarterYearStart().

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

◆ GWEN_Date_GetThisYearEnd()

GWEN_DATE * GWEN_Date_GetThisYearEnd ( const GWEN_DATE dt)

Definition at line 956 of file gwendate.c.

References GWEN_Date_fromGregorian(), and GWEN_Date_GetYear().

Here is the call graph for this function:

◆ GWEN_Date_GetThisYearStart()

GWEN_DATE * GWEN_Date_GetThisYearStart ( const GWEN_DATE dt)

Definition at line 949 of file gwendate.c.

References GWEN_Date_fromGregorian(), and GWEN_Date_GetYear().

Referenced by GWEN_Date_GetLastYearEnd(), and GWEN_Date_GetLastYearStart().

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

◆ GWEN_Date_GetYear()

int GWEN_Date_GetYear ( const GWEN_DATE gd)

◆ GWEN_Date_IsLeapYear()

int GWEN_Date_IsLeapYear ( int  y)

Definition at line 339 of file gwendate.c.

Referenced by _daysInMonth(), and GWEN_Date_GetThisMonthEnd().

Here is the caller graph for this function:

◆ GWEN_Date_setJulian()

void GWEN_Date_setJulian ( GWEN_DATE gd,
int  julian 
)

Definition at line 99 of file gwendate.c.

References _writeAsString(), DBG_ERROR, and GWEN_LOGDOMAIN.

Referenced by GWEN_Date_AddDays(), GWEN_Date_fromJulian(), and GWEN_Date_SubDays().

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

◆ GWEN_Date_SubDays()

void GWEN_Date_SubDays ( GWEN_DATE gd,
int  days 
)

Subtract days from the given date.

Definition at line 167 of file gwendate.c.

References GWEN_Date_setJulian().

Here is the call graph for this function:

◆ GWEN_Date_toDb()

int GWEN_Date_toDb ( const GWEN_DATE dt,
GWEN_DB_NODE db 
)

Definition at line 800 of file gwendate.c.

References GWEN_Date_GetString(), GWEN_DB_FLAGS_OVERWRITE_VARS, and GWEN_DB_SetCharValue().

Here is the call graph for this function:

◆ GWEN_Date_toLocalTime()

time_t GWEN_Date_toLocalTime ( const GWEN_DATE gd)

Definition at line 202 of file gwendate.c.

Referenced by test_date().

Here is the caller graph for this function:

◆ GWEN_Date_toStringWithTemplate()

int GWEN_Date_toStringWithTemplate ( const GWEN_DATE t,
const char *  tmpl,
GWEN_BUFFER buf 
)

Definition at line 758 of file gwendate.c.

References GWEN_Buffer_AppendByte(), GWEN_Buffer_AppendString(), GWEN_Date__fillTmplChars(), GWEN_Date__findTmplChar(), and GWEN_Date__sampleTmplChars().

Referenced by _convertAndSetCharValue().

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

◆ GWEN_Date_WeekDay()

int GWEN_Date_WeekDay ( const GWEN_DATE gd)

Definition at line 417 of file gwendate.c.

Referenced by GWEN_Date__fillTmplChars().

Here is the caller graph for this function:

◆ GWEN_DateTmplChar_free()

void GWEN_DateTmplChar_free ( GWEN_DATE_TMPLCHAR *  e)

Definition at line 614 of file gwendate.c.

References GWEN_FREE_OBJECT, and GWEN_LIST_FINI.

◆ GWEN_DateTmplChar_new()

GWEN_DATE_TMPLCHAR * GWEN_DateTmplChar_new ( char  c)

Definition at line 583 of file gwendate.c.

References GWEN_LIST_INIT, and GWEN_NEW_OBJECT.

Referenced by GWEN_Date__sampleTmplChars().

Here is the caller graph for this function:

Variable Documentation

◆ daysInMonth

const uint8_t daysInMonth[12]
static
Initial value:
= {
31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
}

Definition at line 42 of file gwendate.c.

Referenced by _daysInMonth().