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