Package: birthday Version: 1.6.2-4 Severity: normal Tags: patch upstream Hi,
I'd like an option to ouput the date at the end of each line of list view - sometimes e.g. "2 weeks and 2 days time" isn't that user-friendly. A patch is attached that adds the -L switch to do this. Example output: mv3@deskpro108655:$ birthday -L test is 9 years old today. testy is 8 years old in 2 days' time (22 April). zesty is 0 years old in 3 days' time (23 April). Thanks, Matthew -- System Information: Debian Release: buster/sid APT prefers bionic-updates APT policy: (500, 'bionic-updates'), (500, 'bionic-security'), (500, 'bionic'), (100, 'bionic-backports') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.15.0-34-generic (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages birthday depends on: ii libc6 2.27-3ubuntu1 Versions of packages birthday recommends: ii perl 5.26.1-6ubuntu0.3 birthday suggests no packages. -- no debconf information -- The Wellcome Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.
>From dc5d60ff156c9eaf2a07f9db344e5ec724306215 Mon Sep 17 00:00:00 2001 From: Matthew Vernon <m...@sanger.ac.uk> Date: Wed, 20 Mar 2019 15:37:46 +0000 Subject: [PATCH] add -L option to output day and month name in list view --- bdengine.c | 14 ++++++++++++++ birthday.c | 5 ++++- birthday.h | 1 + birthday.man | 4 ++++ debian/changelog | 7 +++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/bdengine.c b/bdengine.c index 7985843..85b96dc 100644 --- a/bdengine.c +++ b/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, char *parm, const struct date *today); 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, prnfunc outf, const struct date *today) { 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,17 @@ void liststrings(struct event *evl, prnfunc outf, const struct date *today) { 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; + tmptime->tm_mon = evl[i].date.month; + if (strftime(tmp,128," (%e %B)",tmptime)) + append(buf, tmp); + else + fatal("strftime failed\n"); + } free(tmp); } } else { diff --git a/birthday.c b/birthday.c index 59daf07..717bdc7 100644 --- a/birthday.c +++ b/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; diff --git a/birthday.h b/birthday.h index 6df7e70..0106701 100644 --- a/birthday.h +++ b/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; diff --git a/birthday.man b/birthday.man index f0f0f6f..2fcde03 100644 --- a/birthday.man +++ b/birthday.man @@ -18,6 +18,7 @@ birthday \- warn about upcoming birthdays and other events .IR total ] .RB [ -i .IR width ] +.RB [ -L ] .SH DESCRIPTION The @@ -70,6 +71,9 @@ days in advance. This overrides any flag given in the file. 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 diff --git a/debian/changelog b/debian/changelog index 56d7c73..2fb2d87 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +birthday (1.6.2-4.1) unstable; urgency=low + + * NMU + * Add a -L option to output day and month name in list view + + -- Matthew Vernon <m...@sanger.ac.uk> Wed, 20 Mar 2019 15:35:55 +0000 + birthday (1.6.2-4) unstable; urgency=low * New maintainer (Closes: 673226). -- 2.17.1