If you look inside a cheap mechanical timeswitch [1], you'll find a synchronous motor the size of a sugar cube, turning 50 or 60 times a second, then half a dozen plastic gears reducing the rotation to 1 turn per day. AC wall clocks follow the same principle, but with a slightly different gear ratio.
This means you don't need a printed circuit board, or any integrated circuits, or anything like that. Such efficiency is how you make a profit, if you're selling timers on Aliexpress for $3.50.
If you're making a digital timeswitch, a quartz crystal might be cheaper, or might not - it depends on the insulation/isolation you think your product requires.
A clock using the power grid as reference might be off by 4 minutes over the day but on average it will be perfectly on time.
"I didn't notice until now" is quite the opposite of happenstance, on par with the PHB mantra "what do we need devops for, anyway, the network seems to be up!" Well it's up because devops is keeping it up. Likewise, the grid doesn't just magically self-balance around 50 Hz.
EDIT: Nevermind, sounds like there are precision concerns that justify using the power grid for timekeeping.
I/you wish.
leftpad would like to have a word
Edit: NPM has engineering challenges, and Node as well...but I would be extremely hesitant to call a library of ~ten LoC "engineering."
UK and EU grids have websites letting you look at frequency history.
There's still an awful lot of infrastructure keyed off having an accurate synchronous time, including billing systems, traffic lights, street lights...
You can use a resistor to lower the voltage and plug in a stepper motor and there is your clock.
When the idea was initially proposed quartz generators were also a bit more expensive so using the grid to synchronize was not a bad idea at all.
Even today it's not the worst idea since it's being kept very close to 50hz. Close enough that you can safely operate an alarm clock from it without being off to far by the end of the day.
There's probably thousands of electrical panels with old DIN rail timers that don't get replaced until they die.