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