registrar

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit dcc7d240f451545eb4486cf5c5ac530f00b8f82c
parent 954eb4d80beaa505d8e7bd5258390d598ea2958c
Author: Juan F. Meleiro <juan@juanmeleiro.mat.br>
Date:   Sun, 28 May 2023 13:16:47 -0300

birthdays: Add script to format bday announcements

Diffstat:
Abirthdays/birthday.fish | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Rbirthdays -> birthdays/list | 0
Abirthdays/template | 15+++++++++++++++
3 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/birthdays/birthday.fish b/birthdays/birthday.fish @@ -0,0 +1,49 @@ +#!/usr/bin/fish + +set WIDTH 80 + +function ord -a num + switch "$num" + case 1 01 + echo st + case 2 02 + echo nd + case 3 03 + echo rd + case '*' + echo th + end +end + +fzf < list | +read date name + +echo $date | read -d '-' birthyear month day + +set currentyear (date +%Y) +set currentstamp (date +%S) +set birthstamp (date +%S -d $date) + +if test (date +%S -d "$currentyear-$month-$day") -gt $currentstamp + # Most recent birthday was last year + set year (math $currentyear - 1) +else + # Most recent birthday was this year + set year $currentyear +end + +set MONTH (env LANG=en date +"%B" -d "$year-$month-$day") +set DATEORD (ord $day) +set COUNT (math "$year - $birthyear") +set COUNTORD (ord "$COUNT") + +set DATE "$day$DATEORD of $MONTH of $year" +set DATELEN (string length "$DATE") +set DATEPAD (repeat (math "floor(($WIDTH - $DATELEN)/2)") " ") +echo $DATEPAD + +m4 --define=DATE="$DATEPAD$DATE" \ + --define=PLAYER="$name" \ + --define=COUNT="$COUNT$COUNTORD" \ + template + diff --git a/birthdays b/birthdays/list diff --git a/birthdays/template b/birthdays/template @@ -0,0 +1,15 @@ +=============================================================================== +Registrar: juan Birthday Announcement 2022-11-28 +=============================================================================== + + Let all who read henceforth know: + +DATE + + is + + PLAYER's COUNT Agoran Birthday! + + Congratulations! + +===============================================================================