Nautical bell: Difference between revisions

Content added Content deleted
m (→‎{{header|Perl 6}}: removed extreaneous contextualizer)
(→‎{{header|Perl 6}}: snazz up a bit with Unicode)
Line 115:
<lang perl6>my @watch = <Middle Morning Forenoon Afternoon Dog First>;
my @ordinal = <One Two Three Four Five Six Seven Eight>;
 
my $thishour;
my $thisminute = '';
 
loop {
my $utc = DateTime.new(time);
Line 126:
bell($thishour, $thisminute);
}
printf "%s%02d:%02d:%02d", "\br" x 9, $utc.hour, $utc.minute, $utc.second;
sleep(1);
}
 
sub bell ($hour, $minute) {
 
my $bells = (($hour % 4) * 2 + $minute div 30) || 8;
 
printf "%s%02d:%02d %9s watch, %6s Bell%s Gone: \t", "\b" x 9, $hour, $minute,
@watch[($hour div 4 - !?($minute + $hour % 4) + 6) % 6],
@ordinal[$bells - 1], $bells == 1 ?? '' !! 's';
 
chime($bells);
 
sub chime ($count) {
for 1 .. $count ->div $one, $two?2 {
print "\a.a♫ " x ?$one;
sleep .25;
sleep(.25);
print "\a. " x ?$two;
sleep .75;
sleep(.75);
}
if $count % 2 {
print "\a♪";
sleep 1;
}
print "\n";
}
}</lang>
{{out}}
 
23<pre>00:3000 First watch, SevenEight Bells Gone: .. .. ..♫ ♫ .
<pre>
00:0030 FirstMiddle watch, Eight Bells One Bell Gone: .. .. .. ..
0001:3000 Middle watch, OneTwo BellBells Gone: .
01:0030 Middle watch, TwoThree Bells Gone: ..
0102:3000 Middle watch, Three Four Bells Gone: ..♫ ♫ .
02:0030 Middle watch, FourFive Bells Gone: .. ..
0203:3000 Middle watch, Five Six Bells Gone: ..♫ ♫ .. .
03:0030 Middle watch, SixSeven Bells Gone: .. .. ..
0304:3000 Middle watch, SevenEight Bells Gone: .. .. ..♫ ♫ .
04:0030 MiddleMorning watch, Eight Bells One Bell Gone: .. .. .. ..
0405:3000 Morning watch, OneTwo BellBells Gone: .
05:0030 Morning watch, TwoThree Bells Gone: ..
0506:3000 Morning watch, Three Four Bells Gone: ..♫ ♫ .
06:0030 Morning watch, FourFive Bells Gone: .. ..
0607:3000 Morning watch, Five Six Bells Gone: ..♫ ♫ .. .
07:0030 Morning watch, SixSeven Bells Gone: .. .. ..
0708:3000 Morning watch, SevenEight Bells Gone: .. .. ..♫ ♫ .
08:0030 MorningForenoon watch, Eight Bells One Bell Gone: .. .. .. ..
0809:3000 Forenoon watch, OneTwo BellBells Gone: .
09:0030 Forenoon watch, TwoThree Bells Gone: ..
0910:3000 Forenoon watch, Three Four Bells Gone: ..♫ ♫ .
10:0030 Forenoon watch, FourFive Bells Gone: .. ..
1011:3000 Forenoon watch, Five Six Bells Gone: ..♫ ♫ .. .
11:0030 Forenoon watch, SixSeven Bells Gone: .. .. ..
1112:3000 Forenoon watch, SevenEight Bells Gone: .. .. ..♫ ♫ .
12:0030 ForenoonAfternoon watch, Eight Bells One Bell Gone: .. .. .. ..
1213:3000 Afternoon watch, OneTwo BellBells Gone: .
13:0030 Afternoon watch, TwoThree Bells Gone: ..
1314:3000 Afternoon watch, Three Four Bells Gone: ..♫ ♫ .
14:0030 Afternoon watch, FourFive Bells Gone: .. ..
1415:3000 Afternoon watch, Five Six Bells Gone: ..♫ ♫ .. .
15:0030 Afternoon watch, SixSeven Bells Gone: .. .. ..
1516:3000 Afternoon watch, SevenEight Bells Gone: .. .. ..♫ ♫ .
16:0030 Afternoon Dog watch, Eight Bells One Bell Gone: .. .. .. ..
1617:3000 Dog watch, OneTwo BellBells Gone: .
17:0030 Dog watch, TwoThree Bells Gone: ..
1718:3000 Dog watch, Three Four Bells Gone: ..♫ ♫ .
18:0030 Dog watch, FourFive Bells Gone: .. ..
1819:3000 Dog watch, Five Six Bells Gone: ..♫ ♫ .. .
19:0030 Dog watch, SixSeven Bells Gone: .. .. ..
1920:3000 Dog watch, SevenEight Bells Gone: .. .. ..♫ ♫ .
20:0030 DogFirst watch, Eight Bells One Bell Gone: .. .. .. ..
2021:3000 First watch, OneTwo BellBells Gone: .
21:0030 First watch, TwoThree Bells Gone: ..
2122:3000 First watch, Three Four Bells Gone: ..♫ ♫ .
22:0030 First watch, FourFive Bells Gone: .. ..
2223:3000 First watch, Five Six Bells Gone: ..♫ ♫ .. .
23:0030 First watch, SixSeven Bells Gone: .. .. .. ♪</pre>
23:30 First watch, Seven Bells Gone: .. .. .. .
</pre>
 
=={{header|REXX}}==