24
A style question Code Golf
I made a console program to show the time, only it’s different times than the ones we know - and involves a very simple account.
It checks the system time, and upon discovering that a minute has passed, it prints the calculated current time on the screen.
Examples of his departure:
35.5787037037037
35.69444444444444
36.388888888888886
However, I would like it to work a little better:
I wish he had the precision of a second, or a . beat
For this, I should be able to create a task connected to the system clock, so that he would warn me precisely at the moment I determined.
I know it’s possible to make one loop infinite, and check the system time thousands of times - but I don’t really like the idea. The ideal would be to have a Listener to inform me that the time has come to perform my task.
Is that possible? How to do it? (Is there any magic, voodoo that allows it?)
- I would like simple examples in different languages
- Console program
- No need to implement . beat’s account
- The idea is to free the program to do other things and have the task started at a precise time in time
- A single language per response!
The account, for those who are curious, is this:
(UTC+1segundos + (UTC+1minutos * 60) + (UTC+1horas * 3600)) / 86.4
Do you want, for example, a certain function to run only at a certain time you set without there being a loop checking the time? I got it right?
– Woss
@Andersoncarloswoss if not possible, the best way to do it with the loop (which can be accurate). if any function can abstract the loop, better - if it can do without the loop even better.
– Daniel
It’s possible, in Python, at least. I just found the first part of the question confusing, where you talk about account, calculated time and time different from the one we know.
– Woss
@Andersoncarloswoss yes, so I said it’s not necessary at the end - my initial goal was to make a clock, if that’s not clear, but I think the interesting exercise is to check the system time the number of times needed to do it accurately.
– Daniel
@Andersoncarloswoss includes the beat account at the end of the question to kill curiosity.
– Daniel
I remember the .beat. It was a play of marketing by a Swiss watchmaker, Swatch, in the ancient times of 1998...
– Wtrmute
@Wtrmute went to meet last week! I saw that they wanted to put a satellite in space just to serve the time - insane!
– Daniel