From f8d53f5ffb5e51f9d6e9156d43491ea5c8ac9039 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 1 Jun 2013 14:15:19 +0200 Subject: Fix handle multiple hourspecs for same weekdays. --- bin/rdf2hours | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/rdf2hours b/bin/rdf2hours index 6fe6472..f40c921 100755 --- a/bin/rdf2hours +++ b/bin/rdf2hours @@ -169,10 +169,6 @@ while ( my $row = $iterator->next ) { $weekdays = 0 unless ($weekdays); my $weekdays_key = titledescribe( $weekdays, $speccomment ); -# FIXME: support multiple specbundles on same days (e.g. Gaardstronomi sommer siesta) -# $weekdays_key .= daterangedescribe($specfrom, $specthrough) -# if ( ($specfrom) and ($specthrough) ); - $data{$category}{$name_key}{name} = $name; $data{$category}{$name_key}{specbundle}{$specbundle_key}{locationcomment} = $locationcomment; $data{$category}{$name_key}{specbundle}{$specbundle_key}{speclabel} = $speclabel; @@ -181,7 +177,10 @@ while ( my $row = $iterator->next ) { $data{$category}{$name_key}{specbundle}{$specbundle_key}{spec}{$weekdays_key}{weekdays} = $weekdays; # TODO: extend SPARQL to cover specs without opens/closes, or drop below check if ($opens and $closes) { - $data{$category}{$name_key}{specbundle}{$specbundle_key}{spec}{$weekdays_key}{spec} = "$opens - $closes"; + my $hours_key = $opens; + $hours_key =~ s/\b(\d)\b/0$1/g; + my $hourrange = "$opens - $closes"; + $data{$category}{$name_key}{specbundle}{$specbundle_key}{spec}{$weekdays_key}{hours}{$hours_key} = $hourrange; $data{$category}{$name_key}{specbundle}{$specbundle_key}{spec}{$weekdays_key}{speccomment} = $speccomment; } } @@ -223,11 +222,14 @@ for my $category ( @category ) { $data{$category}{$name}{specbundle}{$specbundle}{spec}{$weekdays}{speccomment}, ); push @specbundle, br if (@specbundle); - push @specbundle, "\n", span( - span($specdescription, ":"), - "\t", - span($data{$category}{$name}{specbundle}{$specbundle}{spec}{$weekdays}{spec}), - ); + # TODO: Tighten display of additive hours for same weekdays + for my $hours ( sort keys %{ $data{$category}{$name}{specbundle}{$specbundle}{spec}{$weekdays}{hours} } ) { + push @specbundle, "\n", span( + span($specdescription, ":"), + "\t", + span($data{$category}{$name}{specbundle}{$specbundle}{spec}{$weekdays}{hours}{$hours}), + ); + } } # TODO: make simplified html (preferred for Scribus) optional # push @content, p("\n", @specbundle) if (@specbundle); -- cgit v1.2.3