Questions tagged [date]

This challenge is intended to be solved by using, manipulating, accepting as input, outputting, or calculating calendar dates or clock times.

Filter by
Sorted by
Tagged with
31
votes
43answers
7k views

Is it really time?

A time in the format hhMMss is represented by six numbers in the range 0..9 (e.g.100203 for 3 seconds after 2 minutes after 10am (10:02.03), or ...
19
votes
3answers
2k views

Calculate longest Stack Exchange streak

Introduction This challenge is inspired by the Meta Stack Exchange question The longest consecutive days streak; it turns out that the URL ...
43
votes
49answers
9k views

We had a question once which only failed on Sundays

Inspired by We had a unit test once which only failed on Sundays, write a program or function that does nothing but throw an error when it is Sunday, and exit gracefully on any other day. Rules: No ...
12
votes
6answers
1k views

Compute the difference between two days.

Another date-manipulating problem :P Task Write a program or a function that calculates the difference between two dates given by a user. Input & Output Similar to the previous one, inputs ...
11
votes
13answers
1k views

List all palindromic prime dates between 0000-01-01 and 99999-12-31

You know what a palindrome, a prime and a date are. Your task is to list all dates in 100 thousands of years that fulfill all three characteristics. Nevermind anything but the numbers, use the ...
6
votes
19answers
306 views

Which th second now in this year

In this challenge you have to find out which nth second it is now in this year, current date and time now. Or in other words, how many seconds have passed since New Year. An example current Date is (...
12
votes
26answers
2k views

How long ago was this?

The Rules Each submission must be a full program. The program must take input as two comma-separated dates in the form YYYY-MM-DD, and print the number of days ...
30
votes
35answers
5k views

Help, I've mixed my week up!

My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days ...
19
votes
30answers
3k views

Does this month start on a Monday?

June 2020 is a month in which June 1st corresponds to Monday, June 2nd corresponds to Tuesday, ... June 7th corresponds to Sunday. For reference, here's the cal of ...
22
votes
35answers
5k views

What year will it be in n seconds?

You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking ...
30
votes
26answers
8k views

When will Brexit happen?

Well, Brexit happened. And Sky News, being the geniuses they are, have decided to create a countdown on the side of a bus. Your job is to do something similar. The UK leaves the the EU on 31st of ...
14
votes
9answers
2k views

Calculate the date of Easter

Your function or program should take a year as input and return (or print) the date (in the Gregorian calendar) of that years Easter (not the Eastern Orthodox Easter). The date returned should be ...
20
votes
6answers
1k views

Superstitious Programming

Your challenge is extremely simple. Given a year as input, print all the months in that year that will contain a Friday the 13th according to the Gregorian calendar. Note that even though the ...
49
votes
23answers
9k views

Type the Alphabet - as fast as you can!

Your task is to make a program that measures how fast you can type the letters of the English alphabet. The program shall only accept lowercase letters a to ...
18
votes
7answers
1k views

When is the closest Conway's Doomsday?

A quote from MO.SE answer: Although it is well known that Conway was able to quickly calculate the day of the week of any given date, it is less well known that one part of the algorithm is easy to ...
27
votes
63answers
4k views

What's the Date?

Challenge Weirdly, this hasn't been done yet: output the current date. Rules The date format you should follow is as follows: YYYY-MM-DD Where the month and ...
24
votes
13answers
4k views

How long till Halley's Comet returns?

Halley's Comet is the only comet that may appear (i.e. become visible to the naked eye on Earth) twice in a human lifetime. The orbital period of Halley's Comet is not constant: it has varied between ...
20
votes
49answers
3k views

What's the time, chap?

I honestly cannot believe that this is not a question yet on Code Golf, but.... Print the local time (with a.m. or p.m.) as a string to the console, preceded by "It's ". Example: ...
12
votes
3answers
549 views

Festival of ASCII-art lights

Write, in as few characters as possible, a program that takes zero or six command-line arguments menorah menorah YEAR MONTH DAY HOUR MINUTE SECOND (Both forms ...
10
votes
7answers
297 views

Days and months make years

Today's date is quite an interesting one. Let's take a look at why. The date 07/12/2017 (in DD/MM/YYYY date format) can be split ...
72
votes
40answers
6k views

Legen… wait for it…

dary! In events entirely unrelated to what will hopefully happen to me in the next couple of days, I task you to write code that does the following: Print ...
13
votes
28answers
4k views

Cook me a hot dog! [closed]

Sometimes I find myself wanting a hot dog (don't we all) and so I make one. Now to make a hot dog, it is very simple. 1) Put the hot dogs into boiling water 2) Wait for a certain amount of time (...
43
votes
69answers
8k views

Is it a leap year?

This challenge is quite simple. You will take an input which will be a year from 1801 to 2400, and output if it is a leap year or not. Your input will have no newlines or trailing spaces: ...
33
votes
38answers
4k views

Is it Christmas?

Challenge Given that Christmas is: December Month 12 Day 25 Every year, determine today's date, and whether or not today is Christmas. If it is Christmas, you must print ...
29
votes
39answers
3k views

The Last Monday

Monday, October 31st, is Halloween. And it got me thinking -- I wonder what other months have the last day of the month also be a Monday? Input A positive integer in any convenient format ...
56
votes
54answers
7k views

Convert YYYYMM to MMMYY

Basing on this SO question. Challenge is rather simple: given a date period in the format YYYYMM output it in the format MMMYY. ...
6
votes
20answers
620 views

Get delta of days by current hour and added delta of days

Inputs: current hour: from 0 to 23 (inclusive) delta of hours: [current hour] + ...
86
votes
45answers
17k views

Sleep for 1000 years

Some sleep commands implement a delay of an integer number of seconds. However, 232 seconds is only about 100 years. Bug! What if you need a larger delay? Make a ...
6
votes
12answers
754 views

Output ISO8601 date string from seconds and nanoseconds

One reason why ISO8601 is the best date string format, is that you can simply append as much precision as you like. Given 2 integers representing seconds and nanoseconds that have passed since ...
8
votes
16answers
1k views

Calculate Swatch Internet Time

Output the current time of day as Swatch Internet Time. Specifically, output a three-digit (zero-padded) number of ".beats" (1000ths of a day) which represent the current time of day in the Swatch ...
13
votes
13answers
1k views

The Tenacious Thai Calendar

In the Thai calendar the year 2017 corresponds to 2560. The Thai calendar is always 543 years ahead of the Gregorian calendar. Observant coders will note that 2560 is equal to \$2^9 \times 5\$, in ...
25
votes
43answers
4k views

100 Day Countdown

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 ...
24
votes
16answers
2k views

Prime Wednesdays

Prime Wednesdays Your task is to count the number of Wednesdays that fall on a prime day of the month in a particular year. For instance, 7-13-16 is a prime ...
7
votes
14answers
2k views

Print out execution time of program [closed]

Challenge Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution ...
36
votes
28answers
9k views

Stop, stand there where you are!

Challenge Write a function which takes one parameter: an integer t. Your function has to stop your program for t seconds before ...
19
votes
25answers
5k views

The Work Day Countdown

I just had a genius idea for making the work-life easier - a countdown to a specific date which only counts workdays. The basic task is to create a countdown to a specific date which only includes ...
24
votes
14answers
2k views

Prime Time Travel

Don't tell anyone, but I've nicked my uncle's time travel machine! My uncle is obsessed with prime numbers, though, and that shows in the machine — he has programmed it so that it can only go to dates ...
46
votes
28answers
3k views

Big Ben goes BONG

Your task is to create a program that is to mimic Big Ben (Twitter). Task Whenever a new hour has begun (according to your computer's local time or UTC), you have to output ...
28
votes
7answers
2k views

Compute the RFC 2550 timestamp

RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and ...
6
votes
7answers
731 views

Arbitrary Clock Time Calculator

Create a routine to calculate the position of each unit of a clock with an arbitrary number of units (minutes, hours, half-days, days, years, parsecs, quarter-quells, etc), where each unit can be ...
25
votes
29answers
4k views

How many days in a month?

Given a textual representation (case-insensitive full name or 3 character abbreviation) of a month return the number of days in the month. For example, december, <...
15
votes
10answers
2k views

When does hh:mm = mm.ss?

Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00. Clock: The clock employs ...
14
votes
4answers
896 views

Eight days a week

Back in 1965, The Beatles released their hit song 'Eight Days a Week'. In this code-golf challenge we are going to reimagine dates of the 21st century as if there really were eight days a week. Input ...
69
votes
20answers
6k views

Automate Saving the World

You are Desmond Hume. For the last 3 years, you and your partner, Kelvin, have been slave to a computer that requires a very specific sequence to be entered into it every 108 minutes to save the world....
-1
votes
8answers
1k views

Make a Ramanujan magic square

Background As you maybe know Ramanujan made this magic square by \$4x4\$ Matrix: This works like all magic squares. But the special thing in this square is that his birthdate is hidden in the first ...
73
votes
34answers
11k views

Wait a minute – in less than ten seconds

Task Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half). The program/function must terminate within 10 seconds ...
8
votes
4answers
496 views

Find the date that is n days from January 1st 1984

This challenge is a relatively simple concept that I'm surprised has not been done yet. You will be given only an integer as an input. Your task is to find the date that is this number of days from ...
3
votes
8answers
388 views

Give me the first day of next month

Simple question! Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format. Example inputs: 2018-05-06 ...
18
votes
11answers
3k views

Advent calendar

Let's build an advent Calendar for this Christmas! Many Advent calendars for children take the form of a large rectangular card with numbered windows for each day of December starting from 1 ( ...
6
votes
3answers
245 views

Can I trade today?

Back in 2018, there has been introduced new law in Poland to ban trading on sundays, but certain exceptions have been made (listed below). The task today is to determine, can one trade on the sunday ...

1
2 3 4 5 6