Waiting for 2016

6

Task

Constantly having to check on television, or the time on your computer to see if its 2016 is a tedious task. Being programmers, we should be able to automate this task. Write a program that will output 2016 when the system time hits Friday, January 01, 2016 00:00:00. or rather 1451624400000 ms since midnight January 1, 1970.

Input

There will be no input to your program.

Output

Your program will output 2016 to STDOUT or the equivalent when the system time hits 1451624400000. The maximum allowed delay is 1 second or 1000 ms. If your program is started after 1451624400000, it should not output anything (an empty string is fine) and terminate normally.

Rules

  • Your code must be a full program, not just a function.
  • You can assume your program will be started after midnight January 1, 1970.
  • Your program should be able to detect 2016 within a second of it occurring.
  • Your program should terminate after outputting 2016.
  • If your program is started after midnight January 1, 2016, it should not produce any output, or an empty string, and should terminate normally.

Scoring

To keep with the trend of shortcomings in 2015, this is a challenge. The shortest code in bytes wins.

hargasinski

Posted 2015-12-31T19:30:09.503

Reputation: 443

Question was closed 2015-12-31T20:04:12.013

2

Many of Legen… wait for it… and Is it Christmas? solutions seems to be reusable here...

– manatwork – 2015-12-31T19:34:16.690

2

I was actually looking at the Legen… wait for it… challenge. The reason I didn't consider this a duplicate is that this one is easier in that you can hard code the date you're waiting for, so that'll hope allow shortcuts in the code, and also, there isn't a guaranteed output if your code starts after 2016.

– hargasinski – 2015-12-31T19:40:16.730

So when the program is run prior to 2016-01-01, it should wait until 2016 then print and exit? That is, if this were to hypothetically be run in 1986, it would have to continue to run for 30 years? – Alex A. – 2015-12-31T19:52:47.520

Yes, that's right. If it run anytime after Jan 1, 1970 and before Jan 1, 2016, it should run until midnight Jan 1, 2016, print 2016 and then exit – hargasinski – 2015-12-31T20:02:54.357

Answers

4

Pyth, 20 17 bytes

WnJ2016.d3=hZ)IZJ

This is rather simple.

  • J2016: assign J = 2016
  • .d3: gets current year
  • WnJ2016.d3: while current year is not 2016
  • =hZ: increment Z, which starts at 0
  • ): end the loop
  • IZJ: print J (2016) if Z is not zero, i.e. the loop was run at least once

PurkkaKoodari

Posted 2015-12-31T19:30:09.503

Reputation: 16 699

1An alternative to 2016: C\ߠ – LegionMammal978 – 2015-12-31T20:05:53.407

@LegionMammal978 One character less, but would take more bytes. Also, Pyth uses ISO-8859-1. – PurkkaKoodari – 2015-12-31T21:21:28.263

ߠ uses 2 bytes, so it would cancel out. – LegionMammal978 – 2015-12-31T21:24:02.907

@LegionMammal978 Yeah, but then 2016 is still more readable. Also I don't think you can do ߠ in ISO-8859-1 – PurkkaKoodari – 2015-12-31T21:41:51.037

It works on the online interpreter for me. – LegionMammal978 – 2015-12-31T21:43:43.110

4

Mathematica, 53 49 bytes

a:=UnixTime[]<1451606400;If[a,While@a;Print@2016]

Not entirely sure if it works. Will have to wait for another 9 hours...

LegionMammal978

Posted 2015-12-31T19:30:09.503

Reputation: 15 731

LOL and what... just imagine... WHAT if it doesn't work?? :O – nicael – 2015-12-31T20:02:26.403

2You can change the date on your computer. Also, you can come to Finland where it's only 2 more hours ;-) – PurkkaKoodari – 2015-12-31T20:02:56.827