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
15 votes
7 answers
4k views

How many people are awake?

The following data contains the (approximate) population of each UTC timezone in the world (source): ...
enzo's user avatar
  • 1,943
12 votes
10 answers
1k views

Format Datetime in 30-Hour Clock Time

Input a datetime, format the datetime in YYYY-MM-DD HH:mm:ss format using 30-hour clock time. The 30-hour clock time works as: After 6 a.m., it is same as 24-hour ...
tsh's user avatar
  • 34.4k
7 votes
6 answers
378 views

Output 5-line calendar

Given year, month and optionally weekday of 1st, output the calendar of the month. The first week should remain nonempty. For empty cell, fill it with the date where it's supposed to be, in last or ...
l4m2's user avatar
  • 22.3k
11 votes
3 answers
603 views

Write the date in abbreviated Latin

Inspired by How do you write dates in Latin? Challenge Given a month-and-day date, output that date in abbreviated Latin, as explained below. Input Input is flexible, following conventions from other ...
Stef's user avatar
  • 849
14 votes
22 answers
2k views

Decode the date in Christmas Eve format

This is the inverse of "Encode the date in Christmas Eve format." Write a program that takes as input the string Christmas, possibly followed by ...
Someone's user avatar
  • 1,520
15 votes
19 answers
2k views

Last Week Day Of The Month

Introduction This challenge was inspired by a seemingly simple task requested at work that couldn't easily be done in Microsoft Teams. At least not from what we could find! Task Your task, if you ...
I.T Delinquent's user avatar
11 votes
6 answers
1k views

Spell date in Japanese

Objective Given a date, spell it out in Romanized Japanese. I/O Format The input format is flexible. The output format is <month spelling> <day spelling>...
Dannyu NDos's user avatar
  • 5,639
24 votes
45 answers
3k views

Output each second

With roughly one second (plus or minus 10 ms) between outputs, output anything. The first output must be at most one second after the start of the program, but can be as soon as right when the program ...
Dadsdy's user avatar
  • 2,055
1 vote
4 answers
248 views

Get the date of the Nth day of week after the Xth day of week in a given year and month

Introduction In the United States, national elections are normally held on the first Tuesday after the first Monday in November. Challenge Write a program that takes a Year as integer, and a pair of (...
Lawrence Sproul's user avatar
9 votes
5 answers
427 views

Next Time Of Given Pattern

Introduction: Some times using a 24-hour clock are formatted in a nice pattern. For these patterns, we'll have four different categories: ...
Kevin Cruijssen's user avatar
20 votes
31 answers
2k views

Which weekday was it?

This challenge, I hope, is simple to understand. Given a date-string (given in any format you prefer, so long as it has 4 digits of year and 2 digits of day and month), calculate the weekday for the ...
SectorCorruptor's user avatar
18 votes
3 answers
827 views

Universal Unicode Clock

Plot contrivance You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991. You check the computer ...
Wheat Wizard's user avatar
  • 97.6k
5 votes
4 answers
713 views

Which Western Zodiac sign is today?

Task: With the minimum amount of bytes, determine today's Zodiac sign using the programming language of your choice. Rules: This is code golf, the answer with the fewest characters wins. The ...
Crissov's user avatar
  • 439
12 votes
6 answers
548 views

Implement OADD_MONTHS

Introduction A function that adds months to a date (without overflowing ends of months) is implemented in many languages/packages. In Teradata SQL it's ADD_MONTHS, here are some examples: ...
pajonk's user avatar
  • 15.6k
14 votes
10 answers
947 views

Which Advent is it?

I know, a bit late. Challenge Your challenge is, given a date, output if it's not an Advent Sunday, or the Advent Sunday of the year. Rules The \$4^\text{th}\$ Advent is determined by the Sunday ...
math scat's user avatar
  • 8,823
66 votes
52 answers
8k views

Increment The Time

Every digital clock contains a small creature that has to advance the time every minute [citation needed]. Due to the popularty of digital clocks and the popularity of catching them in the wild, they ...
flawr's user avatar
  • 43.8k
16 votes
14 answers
2k views

When's the Listening Party?

A listening party is an event where a bunch of people get together to listen to some music (like a viewing party, but for music). In the age of the internet you can do Listening Parties online with ...
Wheat Wizard's user avatar
  • 97.6k
11 votes
7 answers
991 views

Days of the Week

Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats: A format similar to ...
h.j.k.'s user avatar
  • 721
1 vote
0 answers
69 views

Calculate the ISO week of Gregorian Easter [duplicate]

As in this question, your task – should you choose to accept it – is to calculate the date of Easter Sunday according to the Gregorian Computus (as used in the Catholic Church and most others) when ...
Crissov's user avatar
  • 439
18 votes
32 answers
3k views

Get the day of the year of a given date

Challenge Given two positive integers \$1 \le m \le 12\$ and \$1\le d \le 31\$, representing a month and days into the month, output the amount of days that have passed since January 1st, on a non-...
kaiffeetasse's user avatar
14 votes
6 answers
512 views

When's my weekend finally here?

I like my job, but sometimes it can get a bit tedious and boring. As motivation, I want to know how many hours of work are left before I finally get my two days of weekend and relaxation. I work ...
Ian H.'s user avatar
  • 2,926
6 votes
5 answers
266 views

US Tax Due Dates

Introduction In a standard* (e.g. not 2020) tax year, estimated payments are due quarterly according to the schedule outlined in Publication 505. Payment Period Due Date January 1 – March 31 April ...
arcyqwerty's user avatar
8 votes
5 answers
515 views

When will DST start / end

Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set ...
tsh's user avatar
  • 34.4k
12 votes
8 answers
2k views

Generate a British numberplate

Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX where AA is a "DVLA ...
pxeger's user avatar
  • 23.5k
25 votes
24 answers
3k views

Help me get the day of the week correct

Sometimes, I will think it is one day of the week (e.g Friday) when in reality, it's earlier in the week (e.g Tuesday). Your challenge is to display the number of days my estimates are off by. ...
lyxal's user avatar
  • 32.9k
19 votes
3 answers
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 ...
Glorfindel's user avatar
7 votes
25 answers
555 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 (...
user avatar
23 votes
38 answers
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 ...
user avatar
27 votes
16 answers
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 ...
Dingus's user avatar
  • 11.1k
7 votes
13 answers
3k 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 ...
jaaq's user avatar
  • 617
15 votes
10 answers
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 ...
user avatar
-2 votes
8 answers
4k 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 ...
math scat's user avatar
  • 8,823
15 votes
4 answers
1k 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 ...
Dingus's user avatar
  • 11.1k
8 votes
4 answers
548 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 ...
Daniel H.'s user avatar
  • 3,328
20 votes
35 answers
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 ...
user avatar
6 votes
3 answers
265 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 ...
Kamila Szewczyk's user avatar
31 votes
35 answers
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 ...
maxb's user avatar
  • 6,837
18 votes
7 answers
2k 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 ...
Bubbler's user avatar
  • 75k
25 votes
13 answers
5k views

Is this a legal date? - April Fools' edition

Task A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) ...
RGS's user avatar
  • 14.1k
22 votes
19 answers
4k views

Even a clock that isn't working gets the time right two or three times a day

Context When I was a little kid, I watched a Disney movie where Goofy told his son "Boy, even a broken clock is right two or three times a day." (see this youtube clip, courtesy of @Arnauld). ...
RGS's user avatar
  • 14.1k
17 votes
12 answers
1k views

Day of the week of an ambiguous date

Goal Write a program or function that returns the day of the week for a date, eg. 01/06/2020 -> Mon However, it's unknown if the date is in the format mm/...
Hand-E-Food's user avatar
  • 8,730
9 votes
6 answers
603 views

Pairs of palindromic anagramic dates separated by a palindromic number of days

Definitions: A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when ...
Regis Portalez's user avatar
33 votes
43 answers
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 ...
simonalexander2005's user avatar
33 votes
12 answers
3k views

How many countries are in the European Union?

Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease. Your job is to take a date and ...
Robin Ryder's user avatar
  • 15.5k
7 votes
14 answers
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 ...
Vojtěch Strnad's user avatar
12 votes
17 answers
3k views

How many ACUs do I have?

Posted from sandbox The Intro What is an ACU? This challenge is based on the concept of money and since this is an international community, we all use different currencies, so in keeping with our ...
ElPedro's user avatar
  • 6,389
16 votes
6 answers
3k views

What's the Mayan date?

Just over seven years ago, everybody suddenly stopped talking about the Maya people. It is time to rectify that! For clarification, I am talking about the Mesoamerican Long Count Calendar. Your ...
KeizerHarm's user avatar
  • 1,363
10 votes
4 answers
565 views

When is Hannukah?

Input The input will be a year between 1583 and 2239. We just want to know when Hannukah was or will be in that year. This is information used by millions of people every year and put in calendars ...
user avatar
21 votes
11 answers
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 ( ...
AZTECCO's user avatar
  • 10.7k
4 votes
7 answers
413 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 ...
ToonAlfrink's user avatar
  • 1,274

1
2 3 4 5 6