Encode the date in Christmas Eve format
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
|
show 8 more comments
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
– Black Owl Kai
21 hours ago
@BlackOwlKai what cartoon?
– PyRulez
21 hours ago
4
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
– Black Owl Kai
21 hours ago
2
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
– PyRulez
21 hours ago
You should specify that you mean Dec 25 for "Christmas", unless you want submissions that use a local date or calendar.
– Sparr
20 hours ago
|
show 8 more comments
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
The day this post was published was Christmas Eve. Tomorrow will be Christmas. Yesterday was Christmas Eve Eve. In two days it will be
Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve.
Your job is to take the date the program is run and encode it in Christmas Eve format.
- If your program is run on Christmas, it should output the string "Christmas".
- If your program is not run on Christmas, it should output the string "Christmas", followed by the string " Eve" repeated
ntimes, wherenis the number of days until Christmas.
- Note that this must be based on the next Christmas. For example, if the day is April 26, 2019, you must do your calculation based on December 25, 2019, not any other Christmas.
- Remember to count leap days.
- Christmas is December 25th of every year.
This is code-golf, so the shortest code wins! Note though that the goal is not to find the shortest program in any language, but to find the shortest program in every particular language. For example, if you find the shortest C++ program, then it wins this contest for C++, even if someone finds a shorter program in Python.
code-golf string date
code-golf string date
edited 18 hours ago
asked 22 hours ago
PyRulez
3,40242055
3,40242055
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
– Black Owl Kai
21 hours ago
@BlackOwlKai what cartoon?
– PyRulez
21 hours ago
4
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
– Black Owl Kai
21 hours ago
2
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
– PyRulez
21 hours ago
You should specify that you mean Dec 25 for "Christmas", unless you want submissions that use a local date or calendar.
– Sparr
20 hours ago
|
show 8 more comments
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
– Black Owl Kai
21 hours ago
@BlackOwlKai what cartoon?
– PyRulez
21 hours ago
4
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
– Black Owl Kai
21 hours ago
2
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
– PyRulez
21 hours ago
You should specify that you mean Dec 25 for "Christmas", unless you want submissions that use a local date or calendar.
– Sparr
20 hours ago
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
– Black Owl Kai
21 hours ago
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
– Black Owl Kai
21 hours ago
@BlackOwlKai what cartoon?
– PyRulez
21 hours ago
@BlackOwlKai what cartoon?
– PyRulez
21 hours ago
4
4
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
– Black Owl Kai
21 hours ago
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
– Black Owl Kai
21 hours ago
2
2
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
– PyRulez
21 hours ago
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
– PyRulez
21 hours ago
You should specify that you mean Dec 25 for "Christmas", unless you want submissions that use a local date or calendar.
– Sparr
20 hours ago
You should specify that you mean Dec 25 for "Christmas", unless you want submissions that use a local date or calendar.
– Sparr
20 hours ago
|
show 8 more comments
15 Answers
15
active
oldest
votes
SmileBASIC, 73 71 67 bytes
?"Christmas";
@L?" Eve"*(D!=O);
O=D
DTREAD OUT,M,D
IF M/D-.48GOTO@L
The program prints "Christmas", then prints " Eve" every time a day passes, until it is December 25th. (12/25 = 0.48)
May take up to a year to run.
1
pure genius ...
– FlipTack
9 hours ago
1
This made me Smile...
– Neil
7 hours ago
add a comment |
R, 112 106 bytes
function(x,z=as.Date(paste0(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
You only useyonce so you can just use it directly for 108 bytes.
– Giuseppe
19 hours ago
Also wouldz[z>=0][1]work instead ofmin?
– Giuseppe
19 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
1
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
add a comment |
Perl 6, 61 bytes
say 'Christmas'~' Eve'x(Date.today...^{.month==12&&.day==25})
Try it online!
Date.today ...^ { .month == 12 && .day == 25 } is the sequence of dates starting at today and ending the day before Christmas. The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
add a comment |
Excel formula, 135 bytes
="Christmas"&REPT(" Eve",IF(TODAY()>=DATE(YEAR(TODAY()),12,25),DATE(YEAR(TODAY())+1,12,25)-TODAY(),DATE(YEAR(TODAY()),12,25)-TODAY()))
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
– Neil
1 hour ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
add a comment |
APL (Dyalog Unicode), 76 63 bytesSBCS
Full program. Assumes ⎕IO←0 (zero-indexing).
⎕CY'dfns'
'Christmas',' Eve'⍴⍨4×12 25⍳⍨⍉2↑1↓⍉date(⍳366)+days⎕TS
Try it online!
⎕CY'dfns' copy in the dfns library
⎕TS current time stamp as [year,month,day,hour,min,sec,ms]days[c] find the number of days[n] since 1899-12-31 00:00:00.000(⍳366) add the first 366 integers (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
add a comment |
C# (Visual C# Interactive Compiler), 92 bytes
Write("Christmas");for(var t=DateTime.Now;t.Month<12|t.Day!=25;t=t.AddDays(1))Write(" Eve");
Try it online!
My strategy is pretty straightforward:
- Initialize a loop variable
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
add a comment |
Python 2, 129 bytes / Python 3, 130 bytes
of course, one less byte with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
105 bytes
– tsh
8 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
add a comment |
Red, 89 bytes
does[a: now/date prin"Christmas"while["25-Dec"<> take/part mold a 6][prin" Eve"a: a + 1]]
Try it online!
add a comment |
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
add a comment |
Groovy, 156 bytes
import java.time.LocalDate as D
d=D.now()
c=D.of(d.year,12,25)
'Chistmas'+' Eve'*java.time.temporal.ChronoUnit.DAYS.between(d,d>c?c.withYear(d.year+1):c)
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
T-SQL, 92 bytes
SELECT 'Christmas'+REPLICATE(' Eve',DATEDIFF(DAY,GETDATE(),STR(YEAR(GETDATE()+6))+'-12-25'))
add a comment |
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
add a comment |
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
1
I don't think this works for the 30th of November...
– Neil
11 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
add a comment |
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
add a comment |
PHP, 84 bytes
Probably doesn't work that well.
$d=intval(date("z"));echo("Christmas ".str_repeat("Eve ",(358-$d)<0?724-$d:358-$d));
1
Will this work in leap year?
– tsh
8 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
a little long, but a nice approach. Take a look atdate("L"):1for leap year,0otherwise. Don´t forget to use it for the next year too. Try($d=date(z))>359; you can useChristmas<?=that way.
– Titus
1 hour ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178003%2fencode-the-date-in-christmas-eve-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
15 Answers
15
active
oldest
votes
15 Answers
15
active
oldest
votes
active
oldest
votes
active
oldest
votes
SmileBASIC, 73 71 67 bytes
?"Christmas";
@L?" Eve"*(D!=O);
O=D
DTREAD OUT,M,D
IF M/D-.48GOTO@L
The program prints "Christmas", then prints " Eve" every time a day passes, until it is December 25th. (12/25 = 0.48)
May take up to a year to run.
1
pure genius ...
– FlipTack
9 hours ago
1
This made me Smile...
– Neil
7 hours ago
add a comment |
SmileBASIC, 73 71 67 bytes
?"Christmas";
@L?" Eve"*(D!=O);
O=D
DTREAD OUT,M,D
IF M/D-.48GOTO@L
The program prints "Christmas", then prints " Eve" every time a day passes, until it is December 25th. (12/25 = 0.48)
May take up to a year to run.
1
pure genius ...
– FlipTack
9 hours ago
1
This made me Smile...
– Neil
7 hours ago
add a comment |
SmileBASIC, 73 71 67 bytes
?"Christmas";
@L?" Eve"*(D!=O);
O=D
DTREAD OUT,M,D
IF M/D-.48GOTO@L
The program prints "Christmas", then prints " Eve" every time a day passes, until it is December 25th. (12/25 = 0.48)
May take up to a year to run.
SmileBASIC, 73 71 67 bytes
?"Christmas";
@L?" Eve"*(D!=O);
O=D
DTREAD OUT,M,D
IF M/D-.48GOTO@L
The program prints "Christmas", then prints " Eve" every time a day passes, until it is December 25th. (12/25 = 0.48)
May take up to a year to run.
edited 3 hours ago
answered 9 hours ago
12Me21
4,97911135
4,97911135
1
pure genius ...
– FlipTack
9 hours ago
1
This made me Smile...
– Neil
7 hours ago
add a comment |
1
pure genius ...
– FlipTack
9 hours ago
1
This made me Smile...
– Neil
7 hours ago
1
1
pure genius ...
– FlipTack
9 hours ago
pure genius ...
– FlipTack
9 hours ago
1
1
This made me Smile...
– Neil
7 hours ago
This made me Smile...
– Neil
7 hours ago
add a comment |
R, 112 106 bytes
function(x,z=as.Date(paste0(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
You only useyonce so you can just use it directly for 108 bytes.
– Giuseppe
19 hours ago
Also wouldz[z>=0][1]work instead ofmin?
– Giuseppe
19 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
1
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
add a comment |
R, 112 106 bytes
function(x,z=as.Date(paste0(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
You only useyonce so you can just use it directly for 108 bytes.
– Giuseppe
19 hours ago
Also wouldz[z>=0][1]work instead ofmin?
– Giuseppe
19 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
1
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
add a comment |
R, 112 106 bytes
function(x,z=as.Date(paste0(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
R, 112 106 bytes
function(x,z=as.Date(paste0(strtoi(format(x,"%Y"))+0:1,"-12-25"))-x)cat("Christmas",rep("Eve",z[z>=0][1]))
Try it online!
Explanation: everyone's at church so I have time to do this. Extract the year, coerce to integer. Make vector of that year's Xmas and the next year's Xmas and subtract the input date to get a vector of two differences between the input date and those two Xmases.
Pick the non-negative one and cat "Christmas" with that many "Eves".
edited 19 hours ago
answered 19 hours ago
ngm
3,25924
3,25924
You only useyonce so you can just use it directly for 108 bytes.
– Giuseppe
19 hours ago
Also wouldz[z>=0][1]work instead ofmin?
– Giuseppe
19 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
1
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
add a comment |
You only useyonce so you can just use it directly for 108 bytes.
– Giuseppe
19 hours ago
Also wouldz[z>=0][1]work instead ofmin?
– Giuseppe
19 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
1
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
You only use
y once so you can just use it directly for 108 bytes.– Giuseppe
19 hours ago
You only use
y once so you can just use it directly for 108 bytes.– Giuseppe
19 hours ago
Also would
z[z>=0][1] work instead of min?– Giuseppe
19 hours ago
Also would
z[z>=0][1] work instead of min?– Giuseppe
19 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
73 bytes. According to the last comment, the program must output the text based on the day it runs. Merry christmas BTW ! :D
– digEmAll
10 hours ago
1
1
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
Tweaked yours for 72 bytes, @digEmAll. Merry Christmas!
– J.Doe
9 hours ago
add a comment |
Perl 6, 61 bytes
say 'Christmas'~' Eve'x(Date.today...^{.month==12&&.day==25})
Try it online!
Date.today ...^ { .month == 12 && .day == 25 } is the sequence of dates starting at today and ending the day before Christmas. The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
add a comment |
Perl 6, 61 bytes
say 'Christmas'~' Eve'x(Date.today...^{.month==12&&.day==25})
Try it online!
Date.today ...^ { .month == 12 && .day == 25 } is the sequence of dates starting at today and ending the day before Christmas. The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
add a comment |
Perl 6, 61 bytes
say 'Christmas'~' Eve'x(Date.today...^{.month==12&&.day==25})
Try it online!
Date.today ...^ { .month == 12 && .day == 25 } is the sequence of dates starting at today and ending the day before Christmas. The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
Perl 6, 61 bytes
say 'Christmas'~' Eve'x(Date.today...^{.month==12&&.day==25})
Try it online!
Date.today ...^ { .month == 12 && .day == 25 } is the sequence of dates starting at today and ending the day before Christmas. The string " Eve" is replicated a number of times equal to the length of that sequence, and is output after the string "Christmas".
answered 17 hours ago
Sean
3,30636
3,30636
add a comment |
add a comment |
Excel formula, 135 bytes
="Christmas"&REPT(" Eve",IF(TODAY()>=DATE(YEAR(TODAY()),12,25),DATE(YEAR(TODAY())+1,12,25)-TODAY(),DATE(YEAR(TODAY()),12,25)-TODAY()))
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
– Neil
1 hour ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
add a comment |
Excel formula, 135 bytes
="Christmas"&REPT(" Eve",IF(TODAY()>=DATE(YEAR(TODAY()),12,25),DATE(YEAR(TODAY())+1,12,25)-TODAY(),DATE(YEAR(TODAY()),12,25)-TODAY()))
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
– Neil
1 hour ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
add a comment |
Excel formula, 135 bytes
="Christmas"&REPT(" Eve",IF(TODAY()>=DATE(YEAR(TODAY()),12,25),DATE(YEAR(TODAY())+1,12,25)-TODAY(),DATE(YEAR(TODAY()),12,25)-TODAY()))
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Excel formula, 135 bytes
="Christmas"&REPT(" Eve",IF(TODAY()>=DATE(YEAR(TODAY()),12,25),DATE(YEAR(TODAY())+1,12,25)-TODAY(),DATE(YEAR(TODAY()),12,25)-TODAY()))
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 7 hours ago
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 7 hours ago
Richard Crossley
214
214
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Richard Crossley is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
– Neil
1 hour ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
add a comment |
I thinkYEAR(TODAY()+6)always returns the correct year, thus avoiding the condition.
– Neil
1 hour ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
I think
YEAR(TODAY()+6) always returns the correct year, thus avoiding the condition.– Neil
1 hour ago
I think
YEAR(TODAY()+6) always returns the correct year, thus avoiding the condition.– Neil
1 hour ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
Shouldn't it be > (instead of >=) ?
– targumon
14 mins ago
add a comment |
APL (Dyalog Unicode), 76 63 bytesSBCS
Full program. Assumes ⎕IO←0 (zero-indexing).
⎕CY'dfns'
'Christmas',' Eve'⍴⍨4×12 25⍳⍨⍉2↑1↓⍉date(⍳366)+days⎕TS
Try it online!
⎕CY'dfns' copy in the dfns library
⎕TS current time stamp as [year,month,day,hour,min,sec,ms]days[c] find the number of days[n] since 1899-12-31 00:00:00.000(⍳366) add the first 366 integers (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
add a comment |
APL (Dyalog Unicode), 76 63 bytesSBCS
Full program. Assumes ⎕IO←0 (zero-indexing).
⎕CY'dfns'
'Christmas',' Eve'⍴⍨4×12 25⍳⍨⍉2↑1↓⍉date(⍳366)+days⎕TS
Try it online!
⎕CY'dfns' copy in the dfns library
⎕TS current time stamp as [year,month,day,hour,min,sec,ms]days[c] find the number of days[n] since 1899-12-31 00:00:00.000(⍳366) add the first 366 integers (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
add a comment |
APL (Dyalog Unicode), 76 63 bytesSBCS
Full program. Assumes ⎕IO←0 (zero-indexing).
⎕CY'dfns'
'Christmas',' Eve'⍴⍨4×12 25⍳⍨⍉2↑1↓⍉date(⍳366)+days⎕TS
Try it online!
⎕CY'dfns' copy in the dfns library
⎕TS current time stamp as [year,month,day,hour,min,sec,ms]days[c] find the number of days[n] since 1899-12-31 00:00:00.000(⍳366) add the first 366 integers (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
APL (Dyalog Unicode), 76 63 bytesSBCS
Full program. Assumes ⎕IO←0 (zero-indexing).
⎕CY'dfns'
'Christmas',' Eve'⍴⍨4×12 25⍳⍨⍉2↑1↓⍉date(⍳366)+days⎕TS
Try it online!
⎕CY'dfns' copy in the dfns library
⎕TS current time stamp as [year,month,day,hour,min,sec,ms]days[c] find the number of days[n] since 1899-12-31 00:00:00.000(⍳366) add the first 366 integers (0…365) to thatdate[c] find the dates[n] that correspond to those numbers (366×7 table; one column per unit)⍉ transpose (7×366 table; one row per unit)1↓ drop one row (the years)2↑ take the first two rows (months and days)12 25⍳⍨ find the index of the first Christmas4× multiply that by four' Eve'⍴⍨ use that to reshape the character list'Christmas ', append that to this
[c] code of that function
[n] notes for that function
edited 11 hours ago
answered 12 hours ago
Adám
28.6k269188
28.6k269188
add a comment |
add a comment |
C# (Visual C# Interactive Compiler), 92 bytes
Write("Christmas");for(var t=DateTime.Now;t.Month<12|t.Day!=25;t=t.AddDays(1))Write(" Eve");
Try it online!
My strategy is pretty straightforward:
- Initialize a loop variable
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
add a comment |
C# (Visual C# Interactive Compiler), 92 bytes
Write("Christmas");for(var t=DateTime.Now;t.Month<12|t.Day!=25;t=t.AddDays(1))Write(" Eve");
Try it online!
My strategy is pretty straightforward:
- Initialize a loop variable
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
add a comment |
C# (Visual C# Interactive Compiler), 92 bytes
Write("Christmas");for(var t=DateTime.Now;t.Month<12|t.Day!=25;t=t.AddDays(1))Write(" Eve");
Try it online!
My strategy is pretty straightforward:
- Initialize a loop variable
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
C# (Visual C# Interactive Compiler), 92 bytes
Write("Christmas");for(var t=DateTime.Now;t.Month<12|t.Day!=25;t=t.AddDays(1))Write(" Eve");
Try it online!
My strategy is pretty straightforward:
- Initialize a loop variable
tto the current date - Print
Eveiftis not Christmas - Add a day to
tand repeat
I tried some fancier things, but this way required the fewest bytes.
edited 1 hour ago
answered 13 hours ago
dana
37125
37125
add a comment |
add a comment |
Python 2, 129 bytes / Python 3, 130 bytes
of course, one less byte with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
105 bytes
– tsh
8 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
add a comment |
Python 2, 129 bytes / Python 3, 130 bytes
of course, one less byte with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
105 bytes
– tsh
8 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
add a comment |
Python 2, 129 bytes / Python 3, 130 bytes
of course, one less byte with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
Python 2, 129 bytes / Python 3, 130 bytes
of course, one less byte with Python 2
from datetime import date as D
T=D.today()
Y=T.year
a=(D(Y,12,25)-T).days
print("Christmas"+" Eve"*[a,(D(Y+1,12,25)-T).days][a<0])
edited 15 hours ago
answered 15 hours ago
iBug
1,207729
1,207729
105 bytes
– tsh
8 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
add a comment |
105 bytes
– tsh
8 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
105 bytes
– tsh
8 hours ago
105 bytes
– tsh
8 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
@tsh That's an amazing approach!
– iBug
7 hours ago
add a comment |
Red, 89 bytes
does[a: now/date prin"Christmas"while["25-Dec"<> take/part mold a 6][prin" Eve"a: a + 1]]
Try it online!
add a comment |
Red, 89 bytes
does[a: now/date prin"Christmas"while["25-Dec"<> take/part mold a 6][prin" Eve"a: a + 1]]
Try it online!
add a comment |
Red, 89 bytes
does[a: now/date prin"Christmas"while["25-Dec"<> take/part mold a 6][prin" Eve"a: a + 1]]
Try it online!
Red, 89 bytes
does[a: now/date prin"Christmas"while["25-Dec"<> take/part mold a 6][prin" Eve"a: a + 1]]
Try it online!
answered 12 hours ago
Galen Ivanov
6,29711032
6,29711032
add a comment |
add a comment |
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
add a comment |
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
add a comment |
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
Ruby, 80 bytes
require'date'
t=Date.today
puts'Christmas'+' Eve'*(Date.new((t+6).year,12,25)-t)
Try it online!
Thanks to tsh for his idea
answered 7 hours ago
iBug
1,207729
1,207729
add a comment |
add a comment |
Groovy, 156 bytes
import java.time.LocalDate as D
d=D.now()
c=D.of(d.year,12,25)
'Chistmas'+' Eve'*java.time.temporal.ChronoUnit.DAYS.between(d,d>c?c.withYear(d.year+1):c)
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Groovy, 156 bytes
import java.time.LocalDate as D
d=D.now()
c=D.of(d.year,12,25)
'Chistmas'+' Eve'*java.time.temporal.ChronoUnit.DAYS.between(d,d>c?c.withYear(d.year+1):c)
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
Groovy, 156 bytes
import java.time.LocalDate as D
d=D.now()
c=D.of(d.year,12,25)
'Chistmas'+' Eve'*java.time.temporal.ChronoUnit.DAYS.between(d,d>c?c.withYear(d.year+1):c)
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Groovy, 156 bytes
import java.time.LocalDate as D
d=D.now()
c=D.of(d.year,12,25)
'Chistmas'+' Eve'*java.time.temporal.ChronoUnit.DAYS.between(d,d>c?c.withYear(d.year+1):c)
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 6 hours ago
bdkosher
1011
1011
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
bdkosher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
T-SQL, 92 bytes
SELECT 'Christmas'+REPLICATE(' Eve',DATEDIFF(DAY,GETDATE(),STR(YEAR(GETDATE()+6))+'-12-25'))
add a comment |
T-SQL, 92 bytes
SELECT 'Christmas'+REPLICATE(' Eve',DATEDIFF(DAY,GETDATE(),STR(YEAR(GETDATE()+6))+'-12-25'))
add a comment |
T-SQL, 92 bytes
SELECT 'Christmas'+REPLICATE(' Eve',DATEDIFF(DAY,GETDATE(),STR(YEAR(GETDATE()+6))+'-12-25'))
T-SQL, 92 bytes
SELECT 'Christmas'+REPLICATE(' Eve',DATEDIFF(DAY,GETDATE(),STR(YEAR(GETDATE()+6))+'-12-25'))
answered 1 hour ago
Neil
79.2k744177
79.2k744177
add a comment |
add a comment |
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
add a comment |
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
add a comment |
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
PHP, 61 bytes
Christmas<?for($t=time();date(md,$t+=86400)-1226;)echo" Eve";
Run with -n or try it online.
answered 1 hour ago
Titus
12.9k11237
12.9k11237
add a comment |
add a comment |
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
1
I don't think this works for the 30th of November...
– Neil
11 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
add a comment |
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
1
I don't think this works for the 30th of November...
– Neil
11 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
add a comment |
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
C# (Visual C# Interactive Compiler), 141 bytes
var g=DateTime.Now;Write("Christmas"+string.Concat(Enumerable.Repeat(" Eve",(new DateTime(g.Year+(g.Day>25&g.Month>11?1:0),12,25)-g).Days)));
Try it online!
edited 56 mins ago
answered 16 hours ago
Embodiment of Ignorance
24711
24711
1
I don't think this works for the 30th of November...
– Neil
11 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
add a comment |
1
I don't think this works for the 30th of November...
– Neil
11 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
1
1
I don't think this works for the 30th of November...
– Neil
11 hours ago
I don't think this works for the 30th of November...
– Neil
11 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Fixed now, I forgot to add a check to if it was December or not
– Embodiment of Ignorance
3 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Are you sure about Month > 25?
– Neil
2 hours ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
Fixed it now...
– Embodiment of Ignorance
55 mins ago
add a comment |
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
add a comment |
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
add a comment |
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
MySQL, 102 bytes
pretty much the same as Neil´s T-SQL answer. There seems to be no shorter way in SQL.
select concat("Christmas",repeat(" Eve",datediff(concat(year(now()+interval 6 day),"-12-25"),now())));
Try it online.
answered 20 mins ago
Titus
12.9k11237
12.9k11237
add a comment |
add a comment |
PHP, 84 bytes
Probably doesn't work that well.
$d=intval(date("z"));echo("Christmas ".str_repeat("Eve ",(358-$d)<0?724-$d:358-$d));
1
Will this work in leap year?
– tsh
8 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
a little long, but a nice approach. Take a look atdate("L"):1for leap year,0otherwise. Don´t forget to use it for the next year too. Try($d=date(z))>359; you can useChristmas<?=that way.
– Titus
1 hour ago
add a comment |
PHP, 84 bytes
Probably doesn't work that well.
$d=intval(date("z"));echo("Christmas ".str_repeat("Eve ",(358-$d)<0?724-$d:358-$d));
1
Will this work in leap year?
– tsh
8 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
a little long, but a nice approach. Take a look atdate("L"):1for leap year,0otherwise. Don´t forget to use it for the next year too. Try($d=date(z))>359; you can useChristmas<?=that way.
– Titus
1 hour ago
add a comment |
PHP, 84 bytes
Probably doesn't work that well.
$d=intval(date("z"));echo("Christmas ".str_repeat("Eve ",(358-$d)<0?724-$d:358-$d));
PHP, 84 bytes
Probably doesn't work that well.
$d=intval(date("z"));echo("Christmas ".str_repeat("Eve ",(358-$d)<0?724-$d:358-$d));
answered 13 hours ago
Adrian Zhang
1975
1975
1
Will this work in leap year?
– tsh
8 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
a little long, but a nice approach. Take a look atdate("L"):1for leap year,0otherwise. Don´t forget to use it for the next year too. Try($d=date(z))>359; you can useChristmas<?=that way.
– Titus
1 hour ago
add a comment |
1
Will this work in leap year?
– tsh
8 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
a little long, but a nice approach. Take a look atdate("L"):1for leap year,0otherwise. Don´t forget to use it for the next year too. Try($d=date(z))>359; you can useChristmas<?=that way.
– Titus
1 hour ago
1
1
Will this work in leap year?
– tsh
8 hours ago
Will this work in leap year?
– tsh
8 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
No sir it will NOT. I have no idea how to implement that.
– Adrian Zhang
3 hours ago
a little long, but a nice approach. Take a look at
date("L"): 1 for leap year, 0 otherwise. Don´t forget to use it for the next year too. Try ($d=date(z))>359; you can use Christmas<?= that way.– Titus
1 hour ago
a little long, but a nice approach. Take a look at
date("L"): 1 for leap year, 0 otherwise. Don´t forget to use it for the next year too. Try ($d=date(z))>359; you can use Christmas<?= that way.– Titus
1 hour ago
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f178003%2fencode-the-date-in-christmas-eve-format%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Somehow I knew that this was going to be a PPCG challenge the moment I saw the cartoon - +1 from me
– Black Owl Kai
21 hours ago
@BlackOwlKai what cartoon?
– PyRulez
21 hours ago
4
A xkcd cartoon that was published today. imgs.xkcd.com/comics/christmas_eve_eve.png
– Black Owl Kai
21 hours ago
2
@BlackOwlKai LMBO I didn't even see that comic until your comment. I had already planned to post this, and was just waiting for Christmas Eve. Great minds think alike, I guess?
– PyRulez
21 hours ago
You should specify that you mean Dec 25 for "Christmas", unless you want submissions that use a local date or calendar.
– Sparr
20 hours ago