xmlElemContent = NULL;
}
+struct tm _init_tm_with_date(const char* date, uint8_t hour, uint8_t min)
+{
+ struct tm value;
+ const time_t now = time(NULL);
+ const struct tm* tmp_now = gmtime(&now);
+ memcpy(&value, tmp_now, sizeof(struct tm));
+
+ if (date != NULL) {
+ value.tm_year = get_year_from_str(date) - 1900;
+ value.tm_mon = get_month_from_str(date) - 1;
+ value.tm_mday = get_day_from_str(date);
+ }
+ value.tm_hour = hour;
+ value.tm_min = min;
+
+ return value;
+}
+
void _write_entry_node(xmlTextWriterPtr xmlWriter,
const char* date,
uint8_t begin_hour,
uint8_t end_min,
time_t last_saldo)
{
- const time_t now = time(NULL);
- const struct tm* tmp_now = gmtime(&now);
- struct tm begin_tm;
- struct tm end_tm;
- memcpy(&begin_tm, tmp_now, sizeof(struct tm));
- memcpy(&end_tm, tmp_now, sizeof(struct tm));
- if (date != NULL) {
- begin_tm.tm_year = get_year_from_str(date) - 1900;
- begin_tm.tm_mon = get_month_from_str(date) - 1;
- begin_tm.tm_mday = get_day_from_str(date);
- end_tm.tm_year = get_year_from_str(date) - 1900;
- end_tm.tm_mon = get_month_from_str(date) - 1;
- end_tm.tm_mday = get_day_from_str(date);
- }
- begin_tm.tm_hour = begin_hour;
- begin_tm.tm_min = begin_min;
- end_tm.tm_hour = end_hour;
- end_tm.tm_min = end_min;
+ const struct tm begin_tm = _init_tm_with_date(date, begin_hour, begin_min);
+ const struct tm end_tm = _init_tm_with_date(date, end_hour, end_min);
const time_t begin = mktime(&begin_tm);
const time_t end = mktime(&end_tm);
const time_t brutto_worktime = get_brutto_worktime(begin, end);