Commit 9a788b34 authored by Michael Rouse's avatar Michael Rouse

Fixed issue with date formatting when adding hours for a specific date. Also...

Fixed issue with date formatting when adding hours for a specific date. Also added better formatting for the report output
parent 8a84398a
......@@ -171,20 +171,20 @@ static void perform_report_action(args_t args)
return;
}
log_info("Running report between %s and %s", startDate.str, endDate.str);
TIMESLIME_DATE_t start = { startDate.year, startDate.month, startDate.day };
TIMESLIME_DATE_t end = { endDate.year, endDate.month, endDate.day };
TIMESLIME_REPORT_t *report;
status = TimeSlime_GetReport(start, end, &report);
log_dull("Time Slime report for %s to %s:", startDate.str, endDate.str);
int i;
for (i = 0; i < report->NumberOfEntries; i++)
{
printf("%s: %0.2f\n", report->Entries[i].Date, report->Entries[i].Hours);
printf("\t%s: %0.2f\n", report->Entries[i].Date, report->Entries[i].Hours);
}
printf("\n");
TimeSlime_FreeReport(&report);
}
......
......@@ -272,7 +272,7 @@ TIMESLIME_STATUS_t TimeSlime_GetReport(TIMESLIME_DATE_t start, TIMESLIME_DATE_t
"SUM(case when HoursAdded <> 0.0 then HoursAdded else ((JULIANDAY(ClockOutTime) - JULIANDAY(ClockInTime)) * 24) end) AS TotalHours, " \
"case when HoursAddedDate IS NOT NULL then date(HoursAddedDate) else date(ClockInTime) end AS TimeSheetDate " \
"FROM TimeSheet " \
"WHERE (%s) AND (TimeSheetDate >= date('%s') AND TimeSheetDate <= date('%s')) " \
"WHERE (%s) AND (TimeSheetDate >= %s AND TimeSheetDate <= %s) " \
"GROUP BY TimeSheetDate " \
"ORDER BY TimeSheetDate ASC",
__TS_QRY_GET_ALL_ENTIRES,
......@@ -534,14 +534,14 @@ static TIMESLIME_STATUS_t _TimeSlime_VerifyDate(TIMESLIME_DATE_t date)
static char* _TimeSlime_Time2Str(TIMESLIME_DATETIME_t time)
{
char *result = (char*)malloc(TIMESLIME_DATETIME_STR_LENGTH * sizeof(char));
sprintf(result, "%04d-%02d-%02d %02d:%02d:0", time.year, time.month, time.day, time.hour, time.minute);
sprintf(result, "datetime('%04d-%02d-%02d %02d:%02d:0')", time.year, time.month, time.day, time.hour, time.minute);
return result;
}
static char* _TimeSlime_Date2Str(TIMESLIME_DATE_t date)
{
char *result = (char*)malloc(TIMESLIME_DATETIME_STR_LENGTH * sizeof(char));
sprintf(result, "%04d-%02d-%02d", date.year, date.month, date.day);
sprintf(result, "date('%04d-%02d-%02d')", date.year, date.month, date.day);
return result;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment