MATLAB - 89 bytes
a=@()hour(now);disp('Legen... wait for it...');while(mod(a()+1,24)~=a())end;disp('dary!')
Pretty self-explanatory. First, create a function handle to grab the current hour of the system clock. Then, display
Legen... wait for it... with a carriage return, and then we go into a
while loop where we keep checking to see if the current hour added with 1 is not equal to the current hour. If it is, keep looping. Only until the instant when the next hour happens, we display
dary! and a carriage return happens after.
MATLAB's hour is based on 24-hour indexing, so the
mod operation with base 24 is required to handle spilling over from 11 p.m. (23:00) to midnight (00:00).
hour function requires the Financial Time Series toolbox. The
now function is not subject to this restriction, but it retrieves the current date and time as a serial number which
hour thus uses to compute the current hour.
Want to run this in Octave?
Sure! Because Octave doesn't have this toolbox, we'd just have to modify the
hour function so that it calls
datevec which returns a vector of 6 elements - one for each of the year, month, day, hour, minutes and seconds. You'd just have to extract out the fourth element of the output:
a=@()datevec(now)(4);disp('Legen... wait for it...');while(mod(a()+1,24)~=a())end;disp('dary!')
The additional characters make the solution go up to 98 bytes, but you'll be able to run this in Octave. Note the in-place indexing without a temporary variable in the function handle.
No Financial Time Series Toolbox?
If you want to run this in MATLAB without the Financial Time Series Toolbox, because you can't index into variables immediately without at temporary one, this will take a bit more bytes to write:
disp('Legen... wait for it...');h=datevec(now);ans=h;while(mod(h(4)+1,24)~=ans(4)),datevec(now);end;disp('dary!');
This first obtains the current time and date and stores it into the variable
h as well as storing this into the automatic variable called
ans. After, we keep looping and checking if the current hour isn't equal to the next hour. At each iteration, we keep updating the automatic variable with the current time and date. As soon as the next hour matches with the current time and date, we display the last part of the string and quit. This pushes the byte count to 114.
Also take note that you can't try this online. Octave interpreters online will have a time limit on when code executes, and because this is a
whileloop waiting for the next hour to happen, you will get a timeout while waiting for the code to run. The best thing you can do is run it on your own machine and check that it works.