Last, next month. Blue.
This commit is contained in:
parent
45c667cdda
commit
d46b5b4d4d
@ -20,6 +20,8 @@ union line64 {
|
|||||||
#define TREE_HEAD
|
#define TREE_HEAD
|
||||||
#include "../src/tree.h"
|
#include "../src/tree.h"
|
||||||
|
|
||||||
|
union date32 date32_last_month(union date32 d);
|
||||||
|
union date32 date32_next_month(union date32 d);
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
struct journal { struct day_tree days; struct char_array backing; };
|
struct journal { struct day_tree days; struct char_array backing; };
|
||||||
struct journal_iterator { struct day_tree_iterator _; };
|
struct journal_iterator { struct day_tree_iterator _; };
|
||||||
|
@ -17,6 +17,16 @@
|
|||||||
#include <sys/stat.h> /* umask (POSIX) */
|
#include <sys/stat.h> /* umask (POSIX) */
|
||||||
#include <dirent.h> /* opendir readdir closedir */
|
#include <dirent.h> /* opendir readdir closedir */
|
||||||
|
|
||||||
|
union date32 date32_last_month(union date32 d) {
|
||||||
|
if(d.month <= 1) d.month = 12, d.year--;
|
||||||
|
else d.month--;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
union date32 date32_next_month(union date32 d) {
|
||||||
|
if(d.month >= 12) d.month = 1, d.year++;
|
||||||
|
else d.month++;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
/* Day tree-map from date to pointer; is backed by a huge array of text. */
|
/* Day tree-map from date to pointer; is backed by a huge array of text. */
|
||||||
void date32_to_string(const union date32 d, char (*const a)[12]) {
|
void date32_to_string(const union date32 d, char (*const a)[12]) {
|
||||||
sprintf(*a, "%" PRIu32 "-%2.2" PRIu32 "-%2.2" PRIu32,
|
sprintf(*a, "%" PRIu32 "-%2.2" PRIu32 "-%2.2" PRIu32,
|
||||||
|
@ -1377,16 +1377,15 @@ void scan_dream_graph(struct scan *const scan) {
|
|||||||
printf("%" PRIu32 "-%.2" PRIu32 ", %zu\n",
|
printf("%" PRIu32 "-%.2" PRIu32 ", %zu\n",
|
||||||
accum.date.year, accum.date.month, accum.count);
|
accum.date.year, accum.date.month, accum.count);
|
||||||
/* If we skip a month, output zero as dummy. */
|
/* If we skip a month, output zero as dummy. */
|
||||||
union date32 next = { .u32 = accum.date.u32 + 32 };
|
const union date32 next = date32_next_month(accum.date);
|
||||||
if(next.u32 < now.u32) {
|
if(next.u32 < now.u32) {
|
||||||
printf("%" PRIu32 "-%.2" PRIu32 ", 0\n",
|
printf("%" PRIu32 "-%.2" PRIu32 ", 0\n",
|
||||||
next.year, next.month);
|
next.year, next.month);
|
||||||
/* Skip more than a month, place dummy output on both. */
|
/* Skip more than a month, place dummy output on both. */
|
||||||
union date32 last = { .u32 = now.u32 - 32 };
|
const union date32 last = date32_last_month(now);
|
||||||
if(next.u32 < last.u32)
|
if(next.u32 < last.u32)
|
||||||
printf("%" PRIu32 "-%.2" PRIu32 ", 0\n",
|
printf("%" PRIu32 "-%.2" PRIu32 ", 0\n",
|
||||||
last.year, last.month);
|
last.year, last.month);
|
||||||
/* fixme: this will not work because it's not packed. */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
accum.date = now;
|
accum.date = now;
|
||||||
@ -1406,8 +1405,8 @@ void scan_dream_graph(struct scan *const scan) {
|
|||||||
"set timefmt \"%%Y-%%m\"\n"
|
"set timefmt \"%%Y-%%m\"\n"
|
||||||
"set format x \"%%Y-%%m\"\n"
|
"set format x \"%%Y-%%m\"\n"
|
||||||
"set style fill transparent solid 0.3\n"
|
"set style fill transparent solid 0.3\n"
|
||||||
|
"set ylabel \"remembered dreams binned by month\"\n"
|
||||||
"\n"
|
"\n"
|
||||||
"plot $Data using 1:2 with boxes notitle\n" /*lc rgb "blue"?*/);
|
"plot $Data using 1:2 with boxes notitle lc rgb \"blue\"\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user