]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
add datum to xml
authorBastian Dehn <hhaalo@arcor.de>
Fri, 21 Jun 2024 20:47:00 +0000 (22:47 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 22 Jun 2024 06:48:17 +0000 (08:48 +0200)
src/feierabendxml.c

index 8e638d2b10aaffcd1726370ae3ed12b33ffd0042..01ecdd3bb428e3c4c8f149804bc25eff6044d389 100644 (file)
@@ -38,7 +38,7 @@ int main(int argc, char* argv[])
        init_feierabend(fabend);
        xmlChar* xmlElemName = xmlCharStrdup("zeitkonto");
        xmlChar* xmlElemContent = NULL;
-       char* wdayshort = malloc(sizeof(char) * 3);
+       char* value = malloc(sizeof(char) * 11);
 
        xmlTextWriterPtr xmlWriter = xmlNewTextWriterFilename("/dev/stdout", 0);
        xmlTextWriterSetIndent(xmlWriter, 8);
@@ -63,20 +63,31 @@ int main(int argc, char* argv[])
        xmlElemName = NULL;
        time(fabend->now);
        fabend->now_tm = gmtime(fabend->now);
-       get_short_weekday(fabend->now_tm->tm_wday, wdayshort);
-       xmlElemContent = xmlCharStrdup(wdayshort);
-       free(wdayshort);
-       wdayshort = NULL;
+       get_short_weekday(fabend->now_tm->tm_wday, value);
+       xmlElemContent = xmlCharStrdup(value);
        xmlElemName = xmlCharStrdup("wochentag");
        xmlTextWriterWriteAttribute(xmlWriter, xmlElemName, xmlElemContent);
        free(xmlElemName);
        xmlElemName = NULL;
        free(xmlElemContent);
        xmlElemContent = NULL;
+       xmlElemName = xmlCharStrdup("datum");
+       sprintf(value, "%04d-%02d-%02d",
+               fabend->now_tm->tm_year + 1900,
+               fabend->now_tm->tm_mon + 1,
+               fabend->now_tm->tm_mday);
+       xmlElemContent = xmlCharStrdup(value);
+       xmlTextWriterWriteAttribute(xmlWriter, xmlElemName, xmlElemContent);
+       free(xmlElemName);
+       xmlElemName = NULL;
+       free(xmlElemContent);
+       xmlElemContent = NULL;
        xmlTextWriterEndElement(xmlWriter);
        xmlTextWriterEndElement(xmlWriter);
        xmlTextWriterEndDocument(xmlWriter);
 
+       free(value);
+       value = NULL;
        free(xmlElemContent);
        xmlElemContent = NULL;
        free(xmlElemName);