50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
/** @license 2023 Neil Edelman, distributed under the terms of the
|
|
[MIT License](https://opensource.org/licenses/MIT).
|
|
|
|
Date _vs_ hours flown. */
|
|
|
|
#include "journal.h"
|
|
#include "flight.h"
|
|
#include "source.h"
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
#include <errno.h>
|
|
|
|
int main(void) {
|
|
int success = EXIT_SUCCESS;
|
|
errno = 0;
|
|
struct journal j = journal();
|
|
struct sources s = sources(&j);
|
|
struct flights f = flights(&j);
|
|
|
|
if(errno) goto catch;
|
|
fprintf(stderr, "Journal: %s.\n", journal_to_string(&j));
|
|
printf("set term postscript eps enhanced\n"
|
|
"set output \"flighthours.eps\"\n"
|
|
"$Data <<EOD\n"
|
|
"# date\tsource\tminutes\tcumulative\n");
|
|
|
|
printf("EOD\n"
|
|
"set monochrome\n"
|
|
"set xdata time\n"
|
|
"set timefmt \"%%Y-%%m-%%d\"\n"
|
|
"set xtics format \"%%Y-%%m-%%d\" rotate by -30\n"
|
|
"set ylabel \"hours\"\n"
|
|
"set format y \"%%g%%%%\"\n"
|
|
"set key top left\n"
|
|
"set grid\n"
|
|
"unset border\n"
|
|
"#set style fill solid 0.1 #pattern 5 (better, but restarts)\n"
|
|
"plot $Data using 1:($3) with fillsteps lw 2\n");
|
|
goto finally;
|
|
catch:
|
|
success = EXIT_FAILURE;
|
|
perror("flights");
|
|
finally:
|
|
flights_(&f);
|
|
sources_(&s);
|
|
journal_(&j);
|
|
return success;
|
|
}
|