51
4
Computers are everywhere nowadays - in cars, trains, skateboards, even nuclear reactors. The possibility that your software will run in a time travelling device is just a matter of time. Can you deal with it? Can you at least detect it?
Your task:
- Write a program that loops and keeps querying the system time, in order to detect time travel.
- If time moves forward a day or more between two consecutive queries, it's forward time travel. In this case, your program should print:
TS TS: YYYY? You mean we're in the future?
- If time moves back, by any amount, between two consecutive queries, it's backward time travel. In this case, your program should print:
TS TS: Back in good old YYYY.
TS TS
are the timestamps before and after the time travel.YYYY
is the destination year.- Timestamps may be in any format, that includes at least the 4-digit year, month, day, hour, minute and second, separated by non-digits.
Limitations:
- You must support dates in the 19th, 20th and 21st centuries, at least.
- You must use a language that existed before this challenge was posted.
- You must post your answers only after this challenge was posted.
- You must use a language that existed before your answer was posted.
- You may edit your answer only after you've posted it.
- Your program must not print any output other than the required output. An occasional "Great Scott!" is allowed.
This is code-golf. The shortest answer wins.
Relevant movie references will probably make your answer too long, but might get you upvotes.
31More falsehoods programmers believe about time, #36: "Time always goes forwards." – Doorknob – 2015-10-21T11:40:29.033
4Could you be a bit more specific about #5? – Mego – 2015-10-21T13:27:38.887
Am I correct to assume that each message should be followed by a newline? – Dennis – 2015-10-21T13:54:39.723
1So, my computer jumps in time whenever I set it to sleep mode? Also, once per year due to the daylight saving time? – John Dvorak – 2015-10-21T15:26:59.073
system time is local time or UTC? – SztupY – 2015-10-21T16:13:56.373
4separated by nondigits? boo. YYYYMMDDHHmmSS is my favorite timestamp format. – Sparr – 2015-10-21T17:13:28.543
@Dennis, yes, it seems obvious to me, but I should clarify. – ugoren – 2015-10-21T18:13:56.237
@SztupY, Whatever you wish. Pacific Daylight Saving Time is also good. – ugoren – 2015-10-21T18:14:41.210
@JanDvorak, Sleep would break this algorithm. But you have to start somewhere. I should have dealt with daylight saving by requiring backward travel to be more than an hour, but I won't edit now because it will break existing answers. – ugoren – 2015-10-21T18:15:53.127
@Sparr, It must be both separated and with nondigits. In your format the nondigits don't separate anything. – ugoren – 2015-10-21T18:17:06.423
@ugoren I recognize that, and I don't like it. Hence the "boo". – Sparr – 2015-10-21T18:18:03.293
@Doorknob, If my question made 11 people (as of now) read your link, I think I did a good job. – ugoren – 2015-10-21T18:18:07.947
What if I change my computer's system time, that's not time travel! – Aequitas – 2015-10-22T04:35:14.800
3@Aequitas how do you know? maybe the system clock is actually immutable and "setting" it is actuallly time traveling – Rune FS – 2015-10-22T05:42:27.160
5Limitation 2,3,4,5 are really harsh, I don't know if I can handle that. – Surt – 2015-10-23T00:10:41.487
2+1 for posing a problem that seems to be unsuitable to be solved with a few chars in one of the esoteric golf scripting languages! – Felix Dombek – 2015-10-23T03:38:59.027
1
@FelixDombek, Yet CJam is the leader...
– ugoren – 2015-10-25T07:47:28.713Wait, no references to Doctor Who in the question? What is this? – mbomb007 – 2015-10-30T15:10:52.467