Douglas McIlroy <[email protected]> writes:
>>If someone knows an elegant way to calculate the number of days from
>> time periods in groff, I'd be very thankful.
>
> How about something like this:
>
> .PS 5i
> define days { line right $1 }
> jan = 31
> feb = 28
> mar = 31
> apr = 30
> may = 31
> ...
> define tick { line up 1
> $1 at last line.s below }
>
> tick("3/15")
> days(mar-15+apr+may+5)
> tick("6/5")
> .PE
Thank you for the starter.
And a bit more work also gives me a horizontal axis with the years, but
I still have to read a lot -- "move 100i" looks a bit strange to me,
the days per year need some scaling, I guess:
.PS 5i
define days { line right $1 }
define diy { # days in year
if $1 == 2024 then {
ndays = 366
} else {
ndays = 365
}
}
jan = 31
feb = 28
mar = 31
apr = 30
may = 31
jun = 30
jul = 31
aug = 31
sep = 30
oct = 31
nov = 30
dec = 31
define tick { line up 1
$1 at last line.s below }
tick("3/15")
days(mar-15+apr+may+5)
tick("6/5")
down;
move 100i;
right;
for i = 2023 to 2025 do
{
diy(i)
if i == 2023 then
{
tick("2023")
}
if i == 2024 then
{
tick("2024")
}
if i == 2025 then
{
tick("2025")
}
line right ndays
}
.PE