gwenhywfar  4.99.15beta
gwentime_all.c
Go to the documentation of this file.
1 /***************************************************************************
2  $RCSfile$
3  -------------------
4  cvs : $Id$
5  begin : Sun Nov 23 2003
6  copyright : (C) 2003 by Martin Preuss
7  email : martin@libchipcard.de
8 
9  ***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
24  * MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 
29 #ifdef HAVE_CONFIG_H
30 # include <config.h>
31 #endif
32 
33 #define DISABLE_DEBUGLOG
34 
35 
36 #include "gwentime_p.h"
37 #include <gwenhywfar/gwentime.h>
38 #include <gwenhywfar/debug.h>
39 
40 #include <time.h>
41 #include <ctype.h>
42 #include <errno.h>
43 #include <string.h>
44 
45 
46 GWEN_LIST_FUNCTIONS(GWEN_TIME_TMPLCHAR, GWEN_TimeTmplChar)
47 
48 
49 
51 {
52  GWEN_TIME *t;
53 
56  DBG_ERROR(GWEN_LOGDOMAIN, "Could not get current time");
57  GWEN_Time_free(t);
58  return 0;
59  }
60  return t;
61 }
62 
63 
64 
66 {
67  GWEN_TIME *t;
68 
70  t->secs=secs;
71  return t;
72 }
73 
74 
75 
77  uint32_t secs)
78 {
79  uint32_t i;
80 
81  assert(ti);
82  i=ti->secs+secs;
83  if (i<ti->secs) {
85  "Overflow when adding %u seconds", secs);
86  return GWEN_ERROR_INVALID;
87  }
88  ti->secs=i;
89  return 0;
90 }
91 
92 
93 
95  uint32_t secs)
96 {
97  assert(ti);
98 
99  if (ti->secs<secs) {
101  "Underflow when subtracting %u seconds",
102  secs);
103  return GWEN_ERROR_INVALID;
104  }
105  ti->secs-=secs;
106  return 0;
107 }
108 
109 
111  uint32_t secs,
112  uint32_t msecs)
113 {
114  assert(ti);
115  ti->secs=secs;
116  ti->msecs=msecs;
117 }
118 
119 
120 
122 {
123  GWEN_DB_NODE *dbT;
124  int i1, i2, i3;
125 
126  assert(t);
127  assert(db);
128  dbT=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "date");
130  "inUtc", 1);
131 
132  assert(dbT);
133  if (GWEN_Time_GetBrokenDownUtcDate(t, &i1, &i2, &i3)) {
134  DBG_INFO(GWEN_LOGDOMAIN, "Could not break down date");
135  return -1;
136  }
138  "day", i1);
140  "month", i2+1);
142  "year", i3);
143 
144  dbT=GWEN_DB_GetGroup(db, GWEN_DB_FLAGS_DEFAULT, "time");
145  assert(dbT);
146  if (GWEN_Time_GetBrokenDownUtcTime(t, &i1, &i2, &i3)) {
147  DBG_INFO(GWEN_LOGDOMAIN, "Could not break down time");
148  return -1;
149  }
151  "hour", i1);
153  "min", i2);
155  "sec", i3);
156 
157  return 0;
158 }
159 
160 
161 
163 {
164  GWEN_TIME *t;
165  GWEN_DB_NODE *dbT;
166  int day, month, year;
167  int hour, min, sec;
168  int inUtc;
169 
170  day=month=year=0;
171  hour=min=sec=0;
172 
173  inUtc=GWEN_DB_GetIntValue(db, "inUtc", 0, 0);
175  if (dbT) {
176  day=GWEN_DB_GetIntValue(dbT, "day", 0, 0);
177  month=GWEN_DB_GetIntValue(dbT, "month", 0, 1)-1;
178  year=GWEN_DB_GetIntValue(dbT, "year", 0, 0);
179  if (!day || !year) {
180  DBG_INFO(GWEN_LOGDOMAIN, "Bad date in DB");
181  return 0;
182  }
183  }
184 
186  if (dbT) {
187  hour=GWEN_DB_GetIntValue(dbT, "hour", 0, 0);
188  min=GWEN_DB_GetIntValue(dbT, "min", 0, 0);
189  sec=GWEN_DB_GetIntValue(dbT, "sec", 0, 0);
190  }
191 
193  "Creating time from this: %04d/%02d/%02d - %02d:%02d:%02d (%d)",
194  year, month, day, hour, min, sec, inUtc);
195  t=GWEN_Time_new(year, month, day, hour, min, sec, inUtc);
196  if (!t) {
197  DBG_INFO(GWEN_LOGDOMAIN, "Bad date/time");
198  return 0;
199  }
200 
201  return t;
202 }
203 
204 
205 
206 GWEN_TIME *GWEN_Time__fromString(const char *s, const char *tmpl, int inUtc)
207 {
208  int year, month, day;
209  int hour, min, sec;
210  const char *p;
211  const char *t;
212  GWEN_TIME *gwt;
213 
214  assert(s);
215  assert(tmpl);
216  year=month=day=0;
217  hour=min=sec=0;
218 
219  p=s;
220  t=tmpl;
221  while (*t && *p) {
222  int i;
223 
224  if (*t=='*') {
225  t++;
226  if (!*t) {
227  DBG_ERROR(GWEN_LOGDOMAIN, "Bad pattern: Must not end with \"*\"");
228  return 0;
229  }
230  i=0;
231  while (*p) {
232  if (!isdigit((int)*p))
233  break;
234  if (*p==*t)
235  break;
236  i*=10;
237  i+=(*p)-'0';
238  p++;
239  } /* while */
240  }
241  else {
242  if (isdigit((int)*p))
243  i=(*p)-'0';
244  else
245  i=-1;
246  p++;
247  }
248 
249  if (i==-1 && strchr("YMDhms", *t)!=NULL) {
251  "No more digits at [%s], continuing", t);
252  p--;
253  }
254  else {
255  switch (*t) {
256  case 'Y':
257  if (i==-1) {
258  DBG_INFO(GWEN_LOGDOMAIN, "here");
259  return 0;
260  }
261  year*=10;
262  year+=i;
263  break;
264  case 'M':
265  if (i==-1) {
266  DBG_INFO(GWEN_LOGDOMAIN, "here");
267  return 0;
268  }
269  month*=10;
270  month+=i;
271  break;
272  case 'D':
273  if (i==-1) {
274  DBG_INFO(GWEN_LOGDOMAIN, "here");
275  return 0;
276  }
277  day*=10;
278  day+=i;
279  break;
280  case 'h':
281  if (i==-1) {
282  DBG_INFO(GWEN_LOGDOMAIN, "here");
283  return 0;
284  }
285  hour*=10;
286  hour+=i;
287  break;
288  case 'm':
289  if (i==-1) {
290  DBG_INFO(GWEN_LOGDOMAIN, "here");
291  return 0;
292  }
293  min*=10;
294  min+=i;
295  break;
296  case 's':
297  if (i==-1) {
298  DBG_INFO(GWEN_LOGDOMAIN, "here");
299  return 0;
300  }
301  sec*=10;
302  sec+=i;
303  break;
304  default:
306  "Unknown character in template, will skip in both strings");
307  break;
308  }
309  }
310  t++;
311  } /* while */
312 
313  if (year<100)
314  year+=2000;
315  if (day==0)
316  day=1;
317 
319  "Got this date/time: %04d/%02d/%02d, %02d:%02d:%02d",
320  year, month-1, day, hour, min, sec);
321 
322  /* get time in local time */
323  gwt=GWEN_Time_new(year, month-1, day, hour, min, sec, inUtc);
324  if (!gwt) {
325  DBG_INFO(GWEN_LOGDOMAIN, "here");
326  return 0;
327  }
328  return gwt;
329 }
330 
331 
332 
333 GWEN_TIME *GWEN_Time_fromString(const char *s, const char *tmpl)
334 {
335  return GWEN_Time__fromString(s, tmpl, 0);
336 }
337 
338 
339 
340 GWEN_TIME *GWEN_Time_fromUtcString(const char *s, const char *tmpl)
341 {
342  return GWEN_Time__fromString(s, tmpl, 1);
343 }
344 
345 
346 
348  int month,
349  int day,
350  int hour,
351  int min,
352  int sec,
353  int inUtc)
354 {
355  uint32_t s;
356 
357  if (inUtc)
358  s=GWEN_Time__mktimeUtc(year, month, day, hour, min, sec);
359  else {
360  struct tm ti;
361  struct tm *tp;
362  time_t tt;
363 
364  tt=time(0);
365  tp=localtime(&tt);
366  assert(tp);
367  memmove(&ti, tp, sizeof(ti));
368  ti.tm_sec=sec;
369  ti.tm_min=min;
370  ti.tm_hour=hour;
371  if (year<100) {
372  if (year<72)
373  year+=2000;
374  year+=1900;
375  }
376  ti.tm_year=year-1900;
377  ti.tm_mon=month;
378  ti.tm_mday=day;
379  ti.tm_yday=0;
380  ti.tm_wday=0;
381  tt=mktime(&ti);
382  assert(tt!=(time_t)-1);
383  s=(uint32_t)tt;
384  }
385  return GWEN_Time_fromSeconds(s);
386 }
387 
388 
389 
390 uint32_t GWEN_Time__mktimeUtc(int year,
391  int month,
392  int day,
393  int hour,
394  int min,
395  int sec)
396 {
397  uint32_t result;
398  int i;
399  int isLeap;
400  const uint32_t hoursecs=60*60;
401  const uint32_t daysecs=24*hoursecs;
402  const uint32_t yearsecs=365*daysecs;
403  const uint32_t monthDays[12]= {
404  31, 28, 31, 30,
405  31, 30, 31, 31,
406  30, 31, 30, 31
407  };
408 
409  result=(year-1970)*yearsecs;
410 
411  for (i=1970; i<year; i++)
412  if ((((i % 4)==0) &&
413  ((i % 100)!=0)) ||
414  ((i % 400)==0))
415  result+=daysecs;
416 
417  isLeap=((((year % 4)==0) &&
418  ((year % 100)!=0)) ||
419  ((year % 400)==0));
420 
421  for (i=0; i<month; i++)
422  if (isLeap && i==1)
423  result+=29*daysecs;
424  else
425  result+=monthDays[i]*daysecs;
426 
427  result+=(day-1)*daysecs;
428  result+=(hour*hoursecs);
429  result+=min*60;
430  result+=sec;
431 
432  return result;
433 }
434 
435 
436 
438 {
439  GWEN_TIME *newT;
440 
441  assert(t);
442  GWEN_NEW_OBJECT(GWEN_TIME, newT);
443  newT->secs=t->secs;
444  newT->msecs=t->msecs;
445  return newT;
446 }
447 
448 
449 
451 {
452  if (t) {
453  GWEN_FREE_OBJECT(t);
454  }
455 }
456 
457 
458 
459 double GWEN_Time_Diff(const GWEN_TIME *t1, const GWEN_TIME *t0)
460 {
461  double d;
462 
463  assert(t1);
464  assert(t0);
465 
466  d=1000.0*((double)(t1->secs)-(double)(t0->secs));
467  d+=(double)((double)(t1->msecs)-(double)(t0->msecs));
468 
469  return d;
470 }
471 
472 
473 
474 double GWEN_Time_DiffSeconds(const GWEN_TIME *t1, const GWEN_TIME *t0)
475 {
476  double d;
477 
478  assert(t1);
479  assert(t0);
480 
481  d=(double)(t1->secs)-(double)(t0->secs);
482  d+=((double)((double)(t1->msecs)-(double)(t0->msecs)))/1000.0;
483 
484  return d;
485 }
486 
487 
488 
489 int GWEN_Time_Compare(const GWEN_TIME *t1, const GWEN_TIME *t0)
490 {
491  if (t1 && t0) {
492  if (t1->secs<t0->secs)
493  return -1;
494  else if (t1->secs>t0->secs)
495  return 1;
496  else {
497  if (t1->msecs<t0->msecs)
498  return -1;
499  else if (t1->msecs>t0->msecs)
500  return 1;
501  else
502  return 0;
503  }
504  }
505  else if (t1)
506  return 1;
507  else if (t0)
508  return -1;
509 
510  return 0;
511 }
512 
513 
514 
516 {
517  assert(t);
518  return (double)((t->secs*1000)+(t->msecs));
519 }
520 
521 
522 
523 uint32_t GWEN_Time_Seconds(const GWEN_TIME *t)
524 {
525  assert(t);
526  return t->secs;
527 }
528 
529 
530 
532  int *hours,
533  int *mins,
534  int *secs)
535 {
536  struct tm *tb;
537  time_t tt;
538 
539  assert(t);
540  tt=t->secs;
541  tb=localtime(&tt);
542  if (!tb) {
543  DBG_ERROR(GWEN_LOGDOMAIN, "localtime(): %s", strerror(errno));
544  return -1;
545  }
546  *hours=tb->tm_hour;
547  *mins=tb->tm_min;
548  *secs=tb->tm_sec;
549  return 0;
550 }
551 
552 
553 
555  int *hours,
556  int *mins,
557  int *secs)
558 {
559  struct tm *tb;
560  time_t tt;
561 
562  assert(t);
563  tt=t->secs;
564  tb=gmtime(&tt);
565  if (!tb) {
566  DBG_ERROR(GWEN_LOGDOMAIN, "gmtime(): %s", strerror(errno));
567  return -1;
568  }
569  *hours=tb->tm_hour;
570  *mins=tb->tm_min;
571  *secs=tb->tm_sec;
572  return 0;
573 }
574 
575 
576 
578  int *days,
579  int *month,
580  int *year)
581 {
582  struct tm *tb;
583  time_t tt;
584 
585  assert(t);
586  tt=t->secs;
587  tb=localtime(&tt);
588  if (!tb) {
589  DBG_ERROR(GWEN_LOGDOMAIN, "localtime(): %s", strerror(errno));
590  return -1;
591  }
592  *days=tb->tm_mday;
593  *month=tb->tm_mon;
594  *year=tb->tm_year+1900;
595  return 0;
596 }
597 
598 
599 
601  int *days,
602  int *month,
603  int *year)
604 {
605  struct tm *tb;
606  time_t tt;
607 
608  assert(t);
609  tt=t->secs;
610  tb=gmtime(&tt);
611  if (!tb) {
612  DBG_ERROR(GWEN_LOGDOMAIN, "gmtime(): %s", strerror(errno));
613  return -1;
614  }
615  *days=tb->tm_mday;
616  *month=tb->tm_mon;
617  *year=tb->tm_year+1900;
618  return 0;
619 }
620 
621 
622 
623 /* TODO: compiler says "function returns an aggregate" */
624 struct tm GWEN_Time_toTm(const GWEN_TIME *t)
625 {
626  struct tm *tb;
627  time_t tt;
628 
629  assert(t);
630  tt=t->secs;
631  tb=localtime(&tt);
632  return *tb;
633 }
634 
636 {
637  assert(t);
638  return t->secs;
639 }
640 
641 
642 
643 
644 GWEN_TIME_TMPLCHAR *GWEN_TimeTmplChar_new(char c)
645 {
646  GWEN_TIME_TMPLCHAR *e;
647 
648  GWEN_NEW_OBJECT(GWEN_TIME_TMPLCHAR, e);
649  GWEN_LIST_INIT(GWEN_TIME_TMPLCHAR, e);
650  e->character=c;
651  return e;
652 }
653 
654 
655 
656 void GWEN_TimeTmplChar_free(GWEN_TIME_TMPLCHAR *e)
657 {
658  if (e) {
659  free(e->content);
660  GWEN_LIST_FINI(GWEN_TIME_TMPLCHAR, e);
661  GWEN_FREE_OBJECT(e);
662  }
663 }
664 
665 
666 GWEN_TIME_TMPLCHAR *GWEN_Time__findTmplChar(GWEN_TIME_TMPLCHAR_LIST *ll,
667  char c)
668 {
669  GWEN_TIME_TMPLCHAR *e;
670 
671  e=GWEN_TimeTmplChar_List_First(ll);
672  while (e) {
673  if (e->character==c)
674  break;
675  e=GWEN_TimeTmplChar_List_Next(e);
676  }
677 
678  return e;
679 }
680 
681 
682 
683 
684 void GWEN_Time__sampleTmplChars(GWEN_UNUSED const GWEN_TIME *t, const char *tmpl,
686  GWEN_TIME_TMPLCHAR_LIST *ll)
687 {
688  const char *s;
689 
690  s=tmpl;
691  while (*s) {
692  if (strchr("YMDhms", *s)) {
693  GWEN_TIME_TMPLCHAR *e;
694 
695  e=GWEN_Time__findTmplChar(ll, *s);
696  if (!e) {
697  /* new entry, create it */
698  e=GWEN_TimeTmplChar_new(*s);
699  GWEN_TimeTmplChar_List_Add(e, ll);
700  }
701  assert(e);
702  e->count++;
703  }
704  else {
705  DBG_DEBUG(GWEN_LOGDOMAIN, "Unknown character in template (%02x)",
706  *s);
707  }
708  s++;
709  }
710 }
711 
712 
713 
715  GWEN_TIME_TMPLCHAR_LIST *ll,
716  int useUtc)
717 {
718  GWEN_TIME_TMPLCHAR *e;
719  int year, month, day, hour, minute, second;
720 
721  if (useUtc) {
722  GWEN_Time_GetBrokenDownUtcDate(t, &day, &month, &year);
723  GWEN_Time_GetBrokenDownUtcTime(t, &hour, &minute, &second);
724  }
725  else {
726  GWEN_Time_GetBrokenDownDate(t, &day, &month, &year);
727  GWEN_Time_GetBrokenDownTime(t, &hour, &minute, &second);
728  }
729 
730  e=GWEN_TimeTmplChar_List_First(ll);
731  while (e) {
732  int v;
733  char buffer[32];
734 
735  switch (e->character) {
736  case 'Y':
737  v=year;
738  break;
739  case 'M':
740  v=month+1;
741  break;
742  case 'D':
743  v=day;
744  break;
745  case 'h':
746  v=hour;
747  break;
748  case 'm':
749  v=minute;
750  break;
751  case 's':
752  v=second;
753  break;
754  default:
755  v=-1;
756  break;
757  }
758  if (v==-1) {
759  DBG_ERROR(GWEN_LOGDOMAIN, "Unknown character, should not happen here");
760  abort();
761  }
762  buffer[0]=0;
763  snprintf(buffer, sizeof(buffer)-1, "%0*d", GWEN_TIME_TMPL_MAX_COUNT, v);
764  buffer[sizeof(buffer)-1]=0;
765  e->content=strdup(buffer);
766  e->nextChar=strlen(e->content)-(e->count);
767  e=GWEN_TimeTmplChar_List_Next(e);
768  }
769 }
770 
771 
772 
773 
774 int GWEN_Time__toString(const GWEN_TIME *t, const char *tmpl,
775  GWEN_BUFFER *buf, int useUtc)
776 {
777  GWEN_TIME_TMPLCHAR_LIST *ll;
778  const char *s;
779 
780  ll=GWEN_TimeTmplChar_List_new();
781  GWEN_Time__sampleTmplChars(t, tmpl, buf, ll);
782  GWEN_Time__fillTmplChars(t, ll, useUtc);
783 
784  s=tmpl;
785  while (*s) {
786  if (strchr("YMDhms", *s)) {
787  GWEN_TIME_TMPLCHAR *e;
788  char c;
789 
790  e=GWEN_Time__findTmplChar(ll, *s);
791  assert(e);
792  assert(e->content);
793  if (s[1]=='*') {
794  /* append full string */
795  GWEN_Buffer_AppendString(buf, e->content);
796  /* skip asterisk */
797  s++;
798  }
799  else {
800  c=e->content[e->nextChar++];
801  assert(c);
802  GWEN_Buffer_AppendByte(buf, c);
803  }
804  }
805  else
806  GWEN_Buffer_AppendByte(buf, *s);
807  s++;
808  }
809  GWEN_TimeTmplChar_List_free(ll);
810  return 0;
811 }
812 
813 
814 
815 int GWEN_Time_toString(const GWEN_TIME *t, const char *tmpl,
816  GWEN_BUFFER *buf)
817 {
818  return GWEN_Time__toString(t, tmpl, buf, 0);
819 }
820 
821 
822 
823 int GWEN_Time_toUtcString(const GWEN_TIME *t, const char *tmpl,
824  GWEN_BUFFER *buf)
825 {
826  return GWEN_Time__toString(t, tmpl, buf, 1);
827 }
828 
829 
830 
831 
832 
833 
834 
835 
836 
837 
struct GWEN_TIME GWEN_TIME
Definition: gwentime.h:43
double GWEN_Time_Diff(const GWEN_TIME *t1, const GWEN_TIME *t0)
Definition: gwentime_all.c:459
int GWEN_Time_GetBrokenDownUtcDate(const GWEN_TIME *t, int *days, int *month, int *year)
Definition: gwentime_all.c:600
void GWEN_Time__fillTmplChars(const GWEN_TIME *t, GWEN_TIME_TMPLCHAR_LIST *ll, int useUtc)
Definition: gwentime_all.c:714
#define GWEN_DB_FLAGS_OVERWRITE_VARS
Definition: db.h:121
struct tm GWEN_Time_toTm(const GWEN_TIME *t)
Definition: gwentime_all.c:624
int GWEN_Time_AddSeconds(GWEN_TIME *ti, uint32_t secs)
Definition: gwentime_all.c:76
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
int GWEN_Time_GetBrokenDownDate(const GWEN_TIME *t, int *days, int *month, int *year)
Definition: gwentime_all.c:577
int GWEN_Time_toDb(const GWEN_TIME *t, GWEN_DB_NODE *db)
Definition: gwentime_all.c:121
#define GWEN_ERROR_INVALID
Definition: error.h:67
double GWEN_Time_DiffSeconds(const GWEN_TIME *t1, const GWEN_TIME *t0)
Definition: gwentime_all.c:474
int GWEN_Time_SubSeconds(GWEN_TIME *ti, uint32_t secs)
Definition: gwentime_all.c:94
int GWEN_Time_Compare(const GWEN_TIME *t1, const GWEN_TIME *t0)
Definition: gwentime_all.c:489
void GWEN_Time__sampleTmplChars(GWEN_UNUSED const GWEN_TIME *t, const char *tmpl, GWEN_UNUSED GWEN_BUFFER *buf, GWEN_TIME_TMPLCHAR_LIST *ll)
Definition: gwentime_all.c:684
uint32_t GWEN_Time_Seconds(const GWEN_TIME *t)
Definition: gwentime_all.c:523
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:92
#define NULL
Definition: binreloc.c:297
#define DBG_VERBOUS(dbg_logger, format, args...)
Definition: debug.h:216
double GWEN_Time_Milliseconds(const GWEN_TIME *t)
Definition: gwentime_all.c:515
GWEN_TIME * GWEN_Time_new(int year, int month, int day, int hour, int min, int sec, int inUtc)
Definition: gwentime_all.c:347
#define GWEN_LOGDOMAIN
Definition: logger.h:35
void GWEN_Time_free(GWEN_TIME *t)
Definition: gwentime_all.c:450
GWEN_TIME * GWEN_Time_fromString(const char *s, const char *tmpl)
Definition: gwentime_all.c:333
int GWEN_Time_GetBrokenDownTime(const GWEN_TIME *t, int *hours, int *mins, int *secs)
Definition: gwentime_all.c:531
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:86
int GWEN_Time_toUtcString(const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)
Definition: gwentime_all.c:823
GWEN_TIME * GWEN_Time_fromDb(GWEN_DB_NODE *db)
Definition: gwentime_all.c:162
#define DBG_DEBUG(dbg_logger, format, args...)
Definition: debug.h:208
GWEN_TIME * GWEN_Time_fromUtcString(const char *s, const char *tmpl)
Definition: gwentime_all.c:340
time_t GWEN_Time_toTime_t(const GWEN_TIME *t)
Definition: gwentime_all.c:635
uint32_t GWEN_Time__mktimeUtc(int year, int month, int day, int hour, int min, int sec)
Definition: gwentime_all.c:390
GWEN_TIME * GWEN_Time_fromSeconds(uint32_t secs)
Definition: gwentime_all.c:65
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
Definition: buffer.c:399
GWEN_DB_NODE * GWEN_DB_GetGroup(GWEN_DB_NODE *n, uint32_t flags, const char *path)
Definition: db.c:1368
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:41
int GWEN_Time__GetCurrentTime(GWEN_TIME *ti)
GWEN_TIME * GWEN_Time_dup(const GWEN_TIME *t)
Definition: gwentime_all.c:437
GWEN_TIME * GWEN_Time__fromString(const char *s, const char *tmpl, int inUtc)
Definition: gwentime_all.c:206
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
GWEN_TIME_TMPLCHAR * GWEN_Time__findTmplChar(GWEN_TIME_TMPLCHAR_LIST *ll, char c)
Definition: gwentime_all.c:666
void GWEN_Time__SetSecsAndMSecs(GWEN_TIME *ti, uint32_t secs, uint32_t msecs)
Definition: gwentime_all.c:110
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:177
GWEN_TIME * GWEN_CurrentTime(void)
Definition: gwentime_all.c:50
GWEN_TIME_TMPLCHAR * GWEN_TimeTmplChar_new(char c)
Definition: gwentime_all.c:644
#define GWEN_LIST_INIT(t, element)
Definition: list1.h:465
int GWEN_DB_GetIntValue(GWEN_DB_NODE *n, const char *path, int idx, int defVal)
Definition: db.c:1150
void GWEN_TimeTmplChar_free(GWEN_TIME_TMPLCHAR *e)
Definition: gwentime_all.c:656
int GWEN_Time_toString(const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf)
Definition: gwentime_all.c:815
int GWEN_Time_GetBrokenDownUtcTime(const GWEN_TIME *t, int *hours, int *mins, int *secs)
Definition: gwentime_all.c:554
int GWEN_DB_SetIntValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
Definition: db.c:1189
#define GWEN_LIST_FUNCTIONS(t, pr)
Definition: list1.h:366
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST
Definition: path.h:84
int GWEN_Time__toString(const GWEN_TIME *t, const char *tmpl, GWEN_BUFFER *buf, int useUtc)
Definition: gwentime_all.c:774
#define GWEN_LIST_FINI(t, element)
Definition: list1.h:474
#define GWEN_UNUSED
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:1062
#define GWEN_DB_FLAGS_DEFAULT
Definition: db.h:168