Nautical bell: Difference between revisions
Content added Content deleted
Line 809: | Line 809: | ||
en.wikipedia.org/wiki/Ship%27s_bell#Simpler_system. |
en.wikipedia.org/wiki/Ship%27s_bell#Simpler_system. |
||
Note the traditional time zone was determined by local sun position |
Note the traditional time zone was determined by local sun position |
||
and so should be |
and so should be local time without daylight savings time. |
||
""" |
""" |
||
function nauticalbells(dt::DateTime) |
function nauticalbells(dt::DateTime) |
||
Line 828: | Line 828: | ||
function nauticalbelltask() |
function nauticalbelltask() |
||
untilnextbell = ceil(now(), Dates.Minute(30)) - now() |
|||
# parse for milliseconds til next hour, start timer with that delay |
|||
⚫ | |||
untilnexthour = now() - DateTime(match(r"^([^:]+)", string(now())).captures[1]) |
|||
⚫ | |||
println("Nautical bell task starting -- next bell in $delay seconds.") |
println("Nautical bell task starting -- next bell in $delay seconds.") |
||
# The timer wakes its task every half hour. May drift very slightly so restart yearly. |
# The timer wakes its task every half hour. May drift very slightly so restart yearly. |
||
Line 837: | Line 836: | ||
wait(timer) |
wait(timer) |
||
gong = nauticalbells(now()) |
gong = nauticalbells(now()) |
||
@async(println("Nautical bell gong strikes $gong!")) # or do |
@async(println("Nautical bell gong strikes $gong!")) # or do audible tones |
||
end |
end |
||
end |
end |