Questions tagged [date]
This challenge is intended to be solved by using, manipulating, accepting as input, outputting, or calculating calendar dates or clock times.
280
questions
16
votes
10
answers
1k
views
Digit Date Range
NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases.
Challenge:
Inputs:
Start date \$s\$; End ...
16
votes
5
answers
2k
views
What's the current zodiac?
Display the emoji of the eastern zodiac of given time, according to given country.
The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a ...
2
votes
0
answers
171
views
Rotated analog clock [closed]
Given:
a 12 hour time t in hours and minutes,
a rotation r in degrees,
return the time shown when an analog clock that is ...
59
votes
13
answers
8k
views
Who was president of the USA?
Challenge
Write a program that takes as input a day from April 30, 1789 to August 21, 2019 and returns as output who was president of the USA that day.
Notes
For the list of US presidents, the ...
6
votes
20
answers
628
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] + ...
24
votes
5
answers
617
views
How long's left?
How long's left?
Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the ...
10
votes
17
answers
1k
views
Tesco's Burger Relish Best Before End date number
Given a date between 2010-01-01 and 2099-12-31 as three integers (please state your order if not [year,month,day]), answer with Tesco's corresponding five-digit ...
26
votes
19
answers
3k
views
Analog is Obtuse!
An analog clock has 2 hands*: Hour and minute.
These hands circle the clock's face as time goes by. Each full rotation of the minute hand results in 1/12th of a rotation of the hour hand. 2 full ...
-1
votes
14
answers
608
views
FizzBuzz but time-based
Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print ...
-6
votes
10
answers
262
views
The year counter is here [closed]
Create a program that, given an integer N, outputs the number of years we have to get to N A.D. or how many years it has been since N A.D, as a string or int. For example, given 2014, the program ...
8
votes
7
answers
818
views
Output the date in the Mel calendar
The Mel calendar is used in the fictional world of Kaldia. Your goal is to convert dates into the Mel calendar.
This calendar has 13 months of 28 days each, plus 1 or 2 extra days after the last ...
36
votes
14
answers
2k
views
Today is the Center
Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the ...
0
votes
1
answer
365
views
Which were the latest 13 consecutive years with the most friday 13. in total? [closed]
Shortest program wins, of course.
22
votes
20
answers
5k
views
It's a yearly task, alright
Given a number 1≤n≤365, output the nth day of the year in "Day-numberth Month" format. For example, given 1, you should output "1st January", without "of".
The Gregorian calendar will be used and the ...
16
votes
9
answers
4k
views
Finding Gaps in Date Ranges
Given a list of date ranges r as input, output or return any ranges not found in r.
For the sake of this example, input will be ...
10
votes
21
answers
2k
views
Unix timestamp to datetime string
Given a unix timestamp as an input, give a datetime string, in a format like so: "YYMMDD.HHmm"
Rules
The input is a number (integer) of a millisecond-precise UNIX epoch time (milliseconds since 1970 ...
8
votes
11
answers
616
views
Mis-decode a date
Background
Inspired by a now deleted question by John Burger from which I quote:
Now obviously no human made this mistake. It's a mis-decode of something - perhaps the ISBN? My question is: ...
20
votes
17
answers
5k
views
Get the date of the nth day of week in a given year and month
Introduction
Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to ...
55
votes
35
answers
7k
views
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
...
16
votes
10
answers
2k
views
Convert an Excel date code to a "date"
Given a non-negative integer Excel-style date code, return the corresponding "date" in any reasonable form that clearly shows year, month, and "day".
Trivial, you may think. Did you notice the "scare ...
12
votes
9
answers
1k
views
Through Space and Time
Introduction:
In general we usually speak of four dimensions: three space dimensions for x, y, and ...
11
votes
5
answers
3k
views
ASCII Calendar Planner
Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two ...
20
votes
26
answers
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 ...
4
votes
4
answers
417
views
Hey, what time is it?
Challenge
Given a number width, number height, hours and ...
14
votes
11
answers
4k
views
A greeting bot for a colleague from work
I have a colleague at work that works from home every Tuesday and Thursday. At around 8:00 AM he sends us a message with the following text:
Hello today I'm working from home
In order to relieve ...
8
votes
18
answers
3k
views
Greet according to the time of day
Challenge
Write a program that greets a user depending on what time of day (GMT) it is.
Output
A string (printed or returned) according to these rules:
If the time is 06:00 to 11:59 the greeting has ...
30
votes
8
answers
3k
views
crossed out 44 is still regular 44 ;(
Introduction
On March 24th, 2015 @isaacg golfed his Pyth answer from 44 to 42 bytes. Since a crossed out 44 (44) looks a lot like a regular 44, @Optimizer made the following comment:
striked out ...
9
votes
11
answers
685
views
The Clock Hands of Doom
You are chained to a chair. Underneath you is a huge volcano. A 12-hour clock next to you ticks ominously, and you see that it has wires leading from the back up to a chain, which will drop you into ...
14
votes
11
answers
951
views
Computing time sheets
Time sheets
In a work place you often have to complete time sheets. This task is write code to help this.
Input
Two times in a slightly non- standard 12 hour clock signifying the start and end of the ...
5
votes
4
answers
492
views
Einstein's Sorter
Challenge
Given a list of integers and a velocity, \$v\$, implement a sorting algorithm which simulates a program sorting the list from smallest to biggest at the given velocity.
Einstein's Theory ...
10
votes
10
answers
439
views
Date Occurrences
Given three non-negative integers y, m, and d (of which at least one must be positive) and a ...
30
votes
24
answers
3k
views
Setting the time
Imagine the following 24-hour clock that can be controlled by arrow keys:
╔══╗ ┌──┐
║00║:│00│
╚══╝ └──┘
HH mm
Pressing the up arrow twice (...
37
votes
6
answers
2k
views
COBOL Y2K redux
In the 1990s, COBOL computer engineers worked out a way to extend six-digit date fields by converting them to YYYDDD where YYY ...
24
votes
14
answers
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 ...
17
votes
16
answers
1k
views
Count the timespans
Inspired by a real-life scenario, which I have asked for an answer to here: https://superuser.com/questions/1312212/writing-a-formula-to-count-how-many-times-each-date-appears-in-a-set-of-date-ran
...
30
votes
22
answers
4k
views
The Time Anagram
Originally posted (and deleted) by @Tlink, which was most likely inspired from this StackOverflow question.
Since it was a shame it got deleted, because it seemed like a good challenge in general, I ...
19
votes
31
answers
2k
views
Date Multiplying Challenge
(Inspired by last week's Riddler on FiveThirtyEight.com. Sandbox post.)
Given a year between 2001 and 2099, calculate and return the number of days during that calendar year where ...
32
votes
9
answers
3k
views
The symmetry of months
Introduction
Some months are completely symmetric, meaning they have central symmetry as well as reflection symmetry, like February of 2010:
...
9
votes
5
answers
407
views
Ticking Quine-Bomb!
Challenge:
Create a program or function that takes an integer input, which outputs a new program/function as specified below.
Input:
Integer n: Time in seconds ...
29
votes
19
answers
4k
views
How old is it roughly?
Write a short program which takes in a positive number of seconds representing an age, and outputs an estimate of that time in English.
Your program must output the least precise amount of time which ...
11
votes
13
answers
2k
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 ...
49
votes
52
answers
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 ...
14
votes
6
answers
813
views
Match the Striking Clock
Introduction:
At home we have a clock that strikes the stated amount at each hour, but also strikes once at every half-hour. So from 0:01 to and including 12:00 it strikes in this order:
...
15
votes
9
answers
760
views
Finding My Favorite Times
I really like times that follow certain patterns. In particular, I like times where all the digits are the same, or all of the digits increase arithmetically by one from left to right. Further, I ...
14
votes
7
answers
785
views
Could They Be The Same Day Of The Week?
Challenge
Given a non-negative integer, output whether it is possible for two dates (of the Gregorian calendar) differing by exactly that many years to share a day of the week. A year is assumed to be ...
25
votes
37
answers
4k
views
Implement a Simple Stopwatch
Challenge
Your task is to write a program which, once a second (including immediately when your program is started), prints the elapsed time from the time your program was started.
Rules
Time must ...
9
votes
1
answer
492
views
The working time calculator
This is based on how my company deals with the monitoring of the working times for every employee. Each one of us has a card that can be passed in front of a sensor, so that a clock registers the ...
10
votes
7
answers
339
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 ...
40
votes
28
answers
11k
views
Happy Birthday, Finland!
Introduction
As is known, in 2017, Finland celebrates its 100 years of independence. To mark the occasion, it is your job to produce a Finnish flag for everyone's enjoyment.
Challenge
Create a ...
8
votes
7
answers
432
views
The Microwave Challenge
Inspired by this comment.
Input
The number of seconds on the timer.
Output
Here's our basic microwave:
...