1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
From: Matthew Vernon <mv3@sanger.ac.uk>
Date: Wed, 20 Mar 2019 15:37:46 +0000
X-Dgit-Generated: 1.6.2-4.1 27699de4cc2e047cc3c396a3d42024788fd65654
Subject: add -L option to output day and month name in list view
---
--- birthday-1.6.2.orig/bdengine.c
+++ birthday-1.6.2/bdengine.c
@@ -63,6 +63,7 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
#ifdef UNIX
#include <sys/types.h>
@@ -83,6 +84,7 @@ struct event *dir_include(char *dir, cha
int iDWarn = DEF_WARN;
int iMaxWarn = MAX_WARN;
int iMinWarn = MIN_WARN;
+int iPrintDate = 0;
const unsigned MLENDAT[]={31,-1,31,30,31,30,31,31,30,31,30,31};
@@ -252,6 +254,7 @@ void liststrings(struct event *evl, prnf
int i,j;
char *buf, *tmp;
int size;
+ struct tm *tmptime;
for (i = 0; evl[i].text != NULL; i++) {
buf = xmalloc(128);
@@ -266,6 +269,19 @@ void liststrings(struct event *evl, prnf
append(buf, " ");
tmp = tdelta(&(evl[i].date), today);
append(buf, tmp);
+ /* only print date if it's not today or tomorrow */
+ if ((iPrintDate > 0) && (delta(&evl[i].date, today) > 1)) {
+ tmptime = (struct tm *)xmalloc(sizeof *tmptime);
+ tmptime = (struct tm *)memset(tmptime,0,(sizeof *tmptime));
+ tmptime->tm_mday = evl[i].date.day;
+ /*struct tm tm_mon is [0-11], our month is [1-12]*/
+ tmptime->tm_mon = evl[i].date.month - 1;
+ if (strftime(tmp,128," (%e %B)",tmptime))
+ append(buf, tmp);
+ else
+ fatal("strftime failed\n");
+ free(tmptime);
+ }
free(tmp);
}
} else {
--- birthday-1.6.2.orig/birthday.c
+++ birthday-1.6.2/birthday.c
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
func = F_WARN;
settoday( &today );
- while ((i = getopt (argc, argv, "wcf:W:M:m:l:p:d:i:T:")) != -1)
+ while ((i = getopt (argc, argv, "wcLf:W:M:m:l:p:d:i:T:")) != -1)
switch (i)
{
case 'w':
@@ -85,6 +85,9 @@ int main(int argc, char *argv[])
case 'l':
iCLines=atoi(optarg);
break;
+ case 'L':
+ iPrintDate = 1;
+ break;
case 'p':
iCWeeks=atoi(optarg);
break;
--- birthday-1.6.2.orig/birthday.h
+++ birthday-1.6.2/birthday.h
@@ -114,6 +114,7 @@ extern struct date today;
extern int iDWarn;
extern int iMaxWarn;
extern int iMinWarn;
+extern int iPrintDate;
extern int iCLines;
extern int iCWidth;
--- birthday-1.6.2.orig/birthday.man
+++ birthday-1.6.2/birthday.man
@@ -18,6 +18,7 @@ birthday \- warn about upcoming birthday
.IR total ]
.RB [ -i
.IR width ]
+.RB [ -L ]
.SH DESCRIPTION
The
@@ -70,6 +71,9 @@ days in advance. This overrides any flag
Warn at least
.I min
days in advance. This overrides any flag given in the file.
+.TP
+.B -L
+Also output the day and name of month after the number of days hence.
.SS Calendar Options
|