aboutsummaryrefslogtreecommitdiff
path: root/mark.fish
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2017-01-09 18:52:42 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2017-01-09 18:52:42 +0100
commitd035f457090dc467e035666978464c5ad2303d79 (patch)
treed2b7ac5ad0d0a8ae6b10fcbee4d9497248772094 /mark.fish
parent837daecb70efb07d94e9f639b6d63bc7d5ccd9d7 (diff)
downloadmark-d035f457090dc467e035666978464c5ad2303d79.tar.gz
mark-d035f457090dc467e035666978464c5ad2303d79.zip
fix and simplify the range extraction
year_offsets are now correct calculated.
Diffstat (limited to 'mark.fish')
-rw-r--r--mark.fish26
1 files changed, 11 insertions, 15 deletions
diff --git a/mark.fish b/mark.fish
index 2df69e5..8e5b348 100644
--- a/mark.fish
+++ b/mark.fish
@@ -61,9 +61,9 @@ function __mark_get --description 'extract information from a mark_store' \
set start_d (string split "-" (date -d @$start_s +%Y-%m-%d))
set year_diff (math $year - $start_d[1])
- set first_year_offset (math "$year_offset + 12*$year_diff")
+ set first_year_offset (math "$year_offset - 13*$year_diff")
- if test $first_year_offset -gt (count marks)
+ if test $first_year_offset -le 0
echo range is to big for available data! >&2
return 1
end
@@ -72,30 +72,26 @@ function __mark_get --description 'extract information from a mark_store' \
# $s = oldest month to add
set s $start_d[2]
set e 12
- for y in (seq $first_year_offset -12 $year_offset)
+ for y in (seq $first_year_offset +13 $year_offset)
# set e if last year is reached
if test $y -eq $year_offset
set e $month
end
for i in (seq $s $e)
- set range_marks $range_marks (string split ":" $marks[(math $y + $i)])[2]
+ set line_marks (string split ":" $marks[(math $y + $i)])[2]
+ # ignore empty lines (years <yyyy>:\n)
+ if not test "" = $line_marks
+ set range_marks $range_marks $line_marks
+ end
end
# reset s -> start with january
set s 0
end
- set marks (string split "" $range_marks[1])
+ set marks (string split "" $range_marks)
+
+ set marks $marks[$start_d[3]..(math $start_d[3] + $range)]
- if test (count $range_marks) -gt 1
- set marks $marks[$start_d[3]..-1]
- for i in (seq 2 (math (count $range_marks) - 1))
- set marks $marks (string split "" $range_marks[$i])
- end
- set tmp_marks (string split "" $range_marks[-1])
- set marks $marks $tmp_marks[1..$day]
- else
- set marks $marks[$start_d[3]..$day]
- end
echo (string join "" $marks)
else
set marks (string split "" (string split ":" $marks[(math $month+$year_offset)])[2])