24
\$\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\$
10
  • 2
    \$\begingroup\$ Can I add the current time to the output? \$\endgroup\$
    – Titus
    Commented Apr 6, 2017 at 4:05
  • 2
    \$\begingroup\$ @Titus no, just the future date \$\endgroup\$ Commented Apr 6, 2017 at 10:30
  • 1
    \$\begingroup\$ Most answers include a date and time now, I think this should be allowed. \$\endgroup\$
    – G B
    Commented Apr 6, 2017 at 12:25
  • 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\$ Commented Apr 6, 2017 at 12:54
  • 2
    \$\begingroup\$ @12431234123412341234123 this format is perfectly readable for me (in fact, it's pretty much a de-facto standard where I live). It all depends on where you're from. \$\endgroup\$ Commented Apr 8, 2017 at 20:30

45 Answers 45

1
2
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\$
6
  • \$\begingroup\$ you forgot a little zero \$\endgroup\$ Commented Apr 7, 2017 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
    Commented Apr 7, 2017 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
    Commented Apr 7, 2017 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
    Commented Apr 7, 2017 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
    Commented Apr 7, 2017 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\$ Uhm, somehow the embracing Date function always returns the current date. Is this code correct? Also, you probably meant to write 864e4 if that is supposed to be the number of seconds in 100 days. Maybe the unit is milliseconds, I don’t know. \$\endgroup\$ Commented Mar 14 at 15:31
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\$
1
\$\begingroup\$

Japt, 9 bytes

Ð864e7+Kj

Test it

My first Japt answer!

A port of the existing JS answer.

\$\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
  • 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\$ Commented Apr 7, 2017 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\$ Commented Apr 7, 2017 at 1:36
  • 1
    \$\begingroup\$ Even so, you can shorten it with an arrow function. \$\endgroup\$ Commented Apr 8, 2017 at 8:15
0
\$\begingroup\$

HP‑41C series, 16 Bytes

This program requires an HP‑41CX or an HP‑41C/CV with a time module plugged in. After energizing the clock’s electronics, the clock is set to January 1, 1900, 0:00 a. m, so set the clock first.

01♦LBL⸆T           5 Bytes  global label requires 4 + (length of string) Bytes
02 DATE            2 Bytes  obtain current date in MM.DDYYYY or DD.MMYYYY format
   NULL            1 Byte   invisible Null byte before numbers
03 100             3 Bytes  push 100 on to the stack (Y ≔ date; X ≔ 100)
04 DATE+           2 Bytes  add 100 days (X) to today’s date (Y) and yield date
05 FIX 6           2 Bytes  ensure _all_ digits of the date are visible
06 RTN             1 Byte   `RTN` does not affect local label search

The X register (the top of the stack) now contains the date in MM.DDYYYY format (or DD.MMYYYY should you have changed that by invoking the DMY command).

Limitations: The result of the DATE+ and other time‑related calculation operations can be “any date from October 15, 1582 (the beginning of the Gregorian calendar) through September 10, 4320” (quoted from the HP‑41CX Owner’s Manual Vol. 2).

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

Swift 5.9, 53 bytes

import Foundation
print("\(Date()+864e4)".prefix(10))
\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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