bugfix: corrected week calculation (iso)

This commit is contained in:
2025-06-12 14:57:36 +02:00
parent 7549acb20c
commit cdc008e361
2 changed files with 29 additions and 19 deletions

View File

@@ -1,17 +1,27 @@
BEGIN { FS="|"; i=0; dlt = -259200; spw = 604800; }
BEGIN { FS="|" }
NR == FNR {
i = i + 1;
from[i] = int(($1 + dlt)/ spw);
from_year[i] = $1
from_week[i] = $2
getline;
to[i] = int(($1 + dlt) / spw);
to_year[i] = $1
to_week[i] = $2
next
} # Load start and end week numbers from first file
{
if (from[FNR] > to[FNR])
print "FNR", FNR, ":", from[FNR],"-",to[FNR], " ",$0;
for(i=from[FNR]; i<=to[FNR]; i++) {
week[i] = week[i] " " $5
year_i = from_year[FNR]
week_i = from_week[FNR]
year_end = to_year[FNR]
week_end = to_week[FNR]
while(year_i <= year_end && (year_i < year_end || week_i <= week_end)) {
label = year_i"|"week_i
week[label] = week[label] " " $5
week_i++
if (week_i > 53) {
week_ = 1
year_i++
}
}
}
END { for (i in week) print i week[i]; }
END { for (label in week) print label week[label]; }