25
\$\begingroup\$

It is common to start countdowns 100 days prior to an event, probably because of our base 10 system. Examples of this can be found everywhere:

  • 100 days until your birthday
  • 100 days until the wedding
  • 100 days until the election
  • 100 days until our graduation
  • 100 days until her due date
  • 100 days until football season
  • 100 days until you get the Fanatic badge

You get the picture. It seems that the 100th day before an event is second place only to the actual event. So for this challenge, I need to know what the date will be in 100 days, so that I can determine what I should start counting down too.

Input

No input

Output

The date 100 days from the current date based on the standard Gregorian Calendar (Make sure to account for leap years). Output is flexible as long as the date format is human read-able (eg 2016-10-8, 10-8-16, [ 2016, 10, 8 ], 10/8/16 12:00:00 AM).

Winning

Code golf: shortest code in bytes


Examples

100 days from today (Apr 5th, 2017) is Friday, July 14 2017.

Current                Future
-------                ------
01/01/2001 +100        04/11/2001
01/01/2004 +100        04/10/2004
01/01/1900 +100        04/11/1900
01/01/2000 +100        04/10/2000

07/04/2017 +100        10/12/2017
10/31/2017 +100        02/08/2018
12/25/2017 +100        04/04/2018

08/29/1941 +100        12/07/1941
06/03/2001 +100        09/11/2001
\$\endgroup\$
  • 2
    \$\begingroup\$ Can I add the current time to the output? \$\endgroup\$ – Titus Apr 6 '17 at 4:05
  • 1
    \$\begingroup\$ @Titus no, just the future date \$\endgroup\$ – NonlinearFruit Apr 6 '17 at 10:30
  • 1
    \$\begingroup\$ Most answers include a date and time now, I think this should be allowed. \$\endgroup\$ – G B Apr 6 '17 at 12:25
  • 1
    \$\begingroup\$ @GB When you output the future date, the format is flexible (could include timestamp) as long as it is human readable. However, current time/date is not acceptable. \$\endgroup\$ – NonlinearFruit Apr 6 '17 at 12:27
  • 5
    \$\begingroup\$ "Because of our bas 10 system"? No, if we counted in binary, we'd likely count down from 100 - except that would take only four days, rather than a hundred... \$\endgroup\$ – Toby Speight Apr 6 '17 at 12:54

42 Answers 42

1
\$\begingroup\$

SAS, 52 bytes

%put%sysfunc(intnx(day,%sysfunc(date()),100),date9.)
\$\endgroup\$
1
\$\begingroup\$

VBA, 8 bytes

?now+100

output:

2017-07-16 10:13:19 

Works in the Immediate Window. Beats Excel by 2 bytes by skipping parentheses.

\$\endgroup\$
1
\$\begingroup\$

R, 16 14 21 bytes

print(Sys.Date()+100)

"2017-07-16"
\$\endgroup\$
  • \$\begingroup\$ you forgot a little zero \$\endgroup\$ – Dan Chaltiel Apr 7 '17 at 9:13
  • \$\begingroup\$ What I mean is that you need a print command. You cannot assume a REPL environment. If you run your code here and it's not printed to Output, then your code isn't a valid solution. \$\endgroup\$ – mbomb007 Apr 7 '17 at 16:03
  • 1
    \$\begingroup\$ @mbomb007 I'd like to see some kind of citation that R must work in TIO. I've never seen an R answer link to TIO. I also just ran this code in a Unix terminal and the output was the same. Can I assume the code is allowed to be run in a terminal? \$\endgroup\$ – BLT Apr 7 '17 at 16:56
  • \$\begingroup\$ codegolf.meta.stackexchange.com/q/2419/8478: Default Program or Function codegolf.meta.stackexchange.com/q/7842/8478: but also REPL \$\endgroup\$ – mbomb007 Apr 7 '17 at 17:24
  • \$\begingroup\$ We treat REPLs as a separate language. So if your code requires a REPL to execute, you should list it as "R REPL" or something similar. In the same way, "Hello, World!" is not a valid "Hello World" program in Python, since it requires print in front to actually print to STDOUT in a non-repl environment. \$\endgroup\$ – mbomb007 Apr 7 '17 at 17:25
1
\$\begingroup\$

Perl 6, 20 bytes

print Date.today+100

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Pyke, 6 bytes

wVs2h

Try it online! (doesn't use literal because I can't figure out how to embed it)

w      -  get 100 in 2 bytes
  Vs2h - Repeat ^ times
   s2  -   increment the day part
     h -  strip the time part

Hexdump:

77 84 56 73 32 68
\$\endgroup\$
1
\$\begingroup\$

AWK, 43 bytes

BEGIN{print strftime("%F",systime()+864e4)}

Could save a few bytes if run using some input... maybe... using something like:

{$0=strftime("%F",systime()+864e4)}1

and running the code like:

awk '{$0=strftime("%F",systime()+864e4)}1'<<<1

But then we have to account for the bytes used to do that. So I'll stick with simplicity :)

\$\endgroup\$
1
\$\begingroup\$

VBScript, 18 bytes

dateadd(d,100,now)
\$\endgroup\$
1
\$\begingroup\$

JavaScript, 21 bytes

Date(+new Date+864e7)

Actually, you don't really need new before Date.

Based on this post.

document.body.innerHTML = Date(+new Date+864e7);

\$\endgroup\$
1
\$\begingroup\$

k6 and q, 8 bytes

.z.d+100

Apparently, .z.d returns the current date, and the default units when adding to dates are days.

Running the command above in q and k6.

\$\endgroup\$
1
\$\begingroup\$

Wolfram Language, 19 bytes

DatePlus[Today,100]

Kinda self-explanatory but let's explain.

DatePlus (From Wolfram Language Reference)

DatePlus[date,{n,"unit"}] gives the date n units after date.

Possible offset units are "Year", "Quarter", "Month", "Week", "Day", "Hour", "Minute", "Second", "Weekday", "Weekend", Monday through Sunday, "EndOfMonth", and "BusinessDay".

Offsets can also be specified using the Quantity framework.

{y,m,d} is taken to be equivalent to {y,m,d,0,0,0} etc.

DatePlus[date,offset] gives results in the same general format as date.

When date is a list, the result has the same length as date, possibly extended to include the smallest unit in offset. »

When date is a string, the result is in the form specified by $DateStringFormat.

Today (From Wolfram Language Reference)

Today
gives a DateObject representing the current day.


So basically, it just adds 100 days to the current date. See screenshot below.


enter image description here

\$\endgroup\$
1
\$\begingroup\$

Matlab/Octave, 16 bytes

datestr(now+100)

Pretty much self-explanatory and (a bit) boring, but could not be missing!

\$\endgroup\$
0
\$\begingroup\$

NodeJS, 96 bytes

require('http').createServer(function(q,s){s.end(':'+new Date(Date.now()+(864e7)))}).listen(8e3)

My first codegolf attempt ever, but I can't find anything to make it shorter.

\$\endgroup\$
  • 3
    \$\begingroup\$ Welcome to PPCG! Just because NodeJS is a server framework, you don't have to make a server to display the output. Something as simple as console.log would suffice for outputting the result :) \$\endgroup\$ – Conor O'Brien Apr 7 '17 at 1:02
  • \$\begingroup\$ @ConorO'Brien true, but I thought it may worth an entry to show, how NodeJS can utilize the same result with it's intended purpose. However, you may argue, whether http server is the sole purpose of the framework, so I admit it may have been unnecessary. \$\endgroup\$ – Zoltán Schmidt Apr 7 '17 at 1:36
  • 1
    \$\begingroup\$ Even so, you can shorten it with an arrow function. \$\endgroup\$ – David Conrad Apr 8 '17 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.