30 #include "gwendate_p.h"
33 #include <gwenhywfar/debug.h>
34 #include <gwenhywfar/misc.h>
43 31,28,31,30,31,30,31,31,30,31,30,31
52 if (m<1 || m>12 || d<1 || d>31) {
61 gd->julian=(1461*(y+4800+(m-14)/12))/4+
62 (367*(m-2-12*((m-14)/12)))/12-
63 (3*((y+4900+(m-14)/12)/100))/4+
66 snprintf(gd->asString,
sizeof(gd->asString)-1,
68 gd->year, gd->month, gd->day);
69 gd->asString[
sizeof(gd->asString)-1]=0;
84 i=(4000*(l+1))/1461001;
87 gd->day=l-(2447*j)/80;
90 gd->year=100*(n-49)+i+l;
93 snprintf(gd->asString,
sizeof(gd->asString)-1,
95 gd->year, gd->month, gd->day);
96 gd->asString[
sizeof(gd->asString)-1]=0;
155 if (3==sscanf(s,
"%04d%02d%02d", &y, &m, &d)) {
175 return ((y%4==0) && (y%100!=0)) || (y%400==0);
184 ((((gd->year%4)==0) && ((gd->year)%100!=0)) || ((gd->year)%400==0)))
200 result=(gd->julian)-(gd11->julian);
238 return (gd->julian+1)%7;
252 if (gd1->julian==gd0->julian)
254 else if (gd1->julian>gd0->julian)
273 return gd1->julian-gd0->julian;
294 int year, month, day;
316 if (!isdigit((
int)*p))
326 if (isdigit((
int)*p))
333 if (i==-1 && strchr(
"YMD", *t)!=
NULL) {
335 "No more digits at [%s], continueing", t);
366 "Unknown character in template, will skip in both strings");
377 "Got this date/time: %04d/%02d/%02d",
397 GWEN_DATE_TMPLCHAR *e;
403 case 'Y': e->maxCount=4;
break;
404 case 'M': e->maxCount=2;
break;
405 case 'D': e->maxCount=2;
break;
406 case 'W': e->maxCount=1;
break;
408 default: e->maxCount=GWEN_DATE_TMPL_MAX_COUNT;
break;
427 GWEN_DATE_TMPLCHAR *e;
429 e=GWEN_DateTmplChar_List_First(ll);
433 e=GWEN_DateTmplChar_List_Next(e);
444 GWEN_DATE_TMPLCHAR_LIST *ll) {
449 if (strchr(
"YMDWw", *s)) {
450 GWEN_DATE_TMPLCHAR *e;
456 GWEN_DateTmplChar_List_Add(e, ll);
472 GWEN_DATE_TMPLCHAR *e;
475 e=GWEN_DateTmplChar_List_First(ll);
479 if (e->character==
'w') {
483 case 0: s=
I18N(
"Sunday");
break;
484 case 1: s=
I18N(
"Monday");
break;
485 case 2: s=
I18N(
"Tuesday");
break;
486 case 3: s=
I18N(
"Wednesday");
break;
487 case 4: s=
I18N(
"Thursday");
break;
488 case 5: s=
I18N(
"Friday");
break;
489 case 6: s=
I18N(
"Saturday");
break;
492 e->content=strdup(s);
499 switch(e->character) {
521 snprintf(buffer,
sizeof(buffer)-1,
"%0*d", e->maxCount, v);
522 buffer[
sizeof(buffer)-1]=0;
523 e->content=strdup(buffer);
525 clen=strlen(e->content);
528 e->nextChar=clen-(e->count);
531 e=GWEN_DateTmplChar_List_Next(e);
539 GWEN_DATE_TMPLCHAR_LIST *ll;
542 ll=GWEN_DateTmplChar_List_new();
548 if (strchr(
"YMDWw", *s)) {
549 GWEN_DATE_TMPLCHAR *e;
562 c=e->content[e->nextChar];
573 GWEN_DateTmplChar_List_free(ll);