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
46 votes
28 answers
4k 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 ...
user41805's user avatar
  • 13.1k
14 votes
4 answers
359 views

Holiday Headache

Warning: DO NOT take medical advice from this post. If you want medical advice, go to a qualified professional. I have a headache. I need headache pills. I'll tell you the last few doses I've had, and ...
Erresen's user avatar
  • 459
35 votes
28 answers
2k views

Merry Golfmas, Everyone!

It's Christmas everybody, and here's a code-golf challenge to celebrate. You need to make a program to print out a present. Specifically, the words "Merry Christmas". BUT, there is a catch: this ...
Leo's user avatar
  • 1,356
53 votes
52 answers
5k views

I'm too cold, turn up the temperature

This is my first golf contest. What you need to do Build me, in the shortest amount of bytes possible, my AC remote control system. My room is too cold right now, and I'm missing my remote. Now, I ...
user avatar
12 votes
9 answers
4k views

Find the nearest Date, given a TargetDate and Day of Week

Find the nearest Date to a TargetDate for a given Day of Week. For example, given a date of 20161219 and a day of week of ...
Brett VanderVeen's user avatar
23 votes
3 answers
861 views

Are we then yet?

I'm a time traveler, and I'm obsessed with the passage of time. I particularly love the moments when the clock hands pass 12, or when I get to flip to the next page of my calendar, or when everyone ...
Jordan's user avatar
  • 9,726
13 votes
1 answer
238 views

For a given period, getting the smallest list of dates, using jokers

Consider a date formatted in YYYY-MM-DD. You can use the joker * at the end of the date string. E.g. ...
Raphael's user avatar
  • 131
29 votes
39 answers
4k 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 ...
AdmBorkBork's user avatar
  • 43.3k
7 votes
3 answers
468 views

World Time Conversion

World Time Conversion Challenge: Given an initial clock time in UTC and a list of countries: for each country in the list, output the local time it is in that country based on the initial time. In ...
Yodle's user avatar
  • 2,408
20 votes
12 answers
879 views

Change the Timezone

Challenge Given a time and a timezone as input, output the time in that timezone. Time The time will be given in 24 hour format like so: hh:mm Where hh is the ...
Beta Decay's user avatar
  • 23.3k
3 votes
1 answer
233 views

Are you a Fanatic?

Write a function or program that awards you SE badges. If an input "Q" is given it means you have asked a question. If no input is given it means you have only visited the site.* Badges it must ...
Stewie Griffin's user avatar
6 votes
3 answers
302 views

When is their birthday?

Donald Knuth was born in 1938, on the 20th day of Capricorn. The first day of Capricorn is the 22nd December. Donald Knuth was born on the 10th of January (1938). The challenge Write a program or ...
Jonathan Allan's user avatar
47 votes
69 answers
8k views

List of possible birth years of living humans

The Challenge Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list. Details The list should be in ...
Christiaan Westerbeek's user avatar
21 votes
21 answers
3k views

Sort the months of the year

Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, ...
Nick T's user avatar
  • 3,307
8 votes
6 answers
539 views

A Fractional Year

My PPCG holiday is over :D Intro Fractional time is the year + (the value (minute of year) / number of minutes in the year). Example calculation You should ...
Beta Decay's user avatar
  • 23.3k
25 votes
16 answers
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 ...
NonlinearFruit's user avatar
17 votes
11 answers
2k views

Legalize Reversed Date

Input: A Date (containing dd, MM and yyyy). A date-object, or three separate integers are ...
Kevin Cruijssen's user avatar
6 votes
4 answers
2k views

Validating a CPR number

Validating a CPR number A Danish CPR number (Person Identification Number) is date of birth followed by 4 digits (the last one being a control digit): DDMMYY-XXXX The final digit validates the CPR ...
Daniel's user avatar
  • 1,928
9 votes
16 answers
2k 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 ...
mystery's user avatar
  • 396
6 votes
10 answers
1k views

I hate Mondays!

You should a program in language X, which will only output its source code (i.e function as a quine) when it is not a monday. On monday it should output some string with a levehnstein distance of 4 ...
Rohan Jhunjhunwala's user avatar
18 votes
13 answers
2k views

Forecast Palindromic Dates

Palindromic dates are dates that appear as palindromes: the string of digits can be read the same way backwards as forwards. For the North American date format (MM/DD/YYYY), the next few palindromic ...
atlasologist's user avatar
  • 2,995
66 votes
65 answers
9k 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. ...
pajonk's user avatar
  • 15.1k
78 votes
37 answers
12k 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 ...
Adám's user avatar
  • 29.9k
9 votes
3 answers
350 views

Simplify a Date

This is similar to simplifying fractions, but with Dates! The input of your program must be of the form mm/dd For example ...
jmasterx's user avatar
  • 519
15 votes
11 answers
1k views

What's the Binary Time?

What's the Binary Time? Everybody knows what the normal time is. It's up there in the top-right (or wherever you put it) of your screen. But a question people rarely seem to ask themselves is this: ...
user avatar
23 votes
34 answers
4k views

24 and 12 Hour Times

Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times: ...
Calvin's Hobbies's user avatar
30 votes
7 answers
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 ...
user avatar
12 votes
3 answers
1k views

420 <s>Blaze</s> Golf It

This is a pretty simple challenge, but (I hope) a fun one. Task If right now either the month is 4 and the day is 20, the hour (...
Maltysen's user avatar
  • 25.7k
12 votes
1 answer
650 views

Beat Pure Regular Expressions at Validating ISO 8601 Dates

In ValiDate ISO 8601 by RX, the challenge was to use only standard regular expressions to validate standard date formats and values (the former is a common job for RX, the latter was unusual). The ...
Crissov's user avatar
  • 439
7 votes
2 answers
405 views

Roman-style date formatting

Today (March 15) is the Ides of March, best known for being the date that Julius Caesar was assassinated. What's “Ides”? Well, the ancient Romans didn't simply number the days of month from 1 to 31 ...
dan04's user avatar
  • 6,581
26 votes
37 answers
8k views

Happy Rounded Pi Day

To celebrate Rounded Pi Day, you must take advantage of today's date to make a program that takes in a circle's diameter and outputs its circumference by multiplying the diameter by 3.1416, where 3....
jmasterx's user avatar
  • 519
5 votes
1 answer
289 views

Graduation Meme Tally [closed]

Now that we're graduating, it's time to tally up the number of times someone suggested that PPCG was graduating, even before the annoucement! (see here) Your program will receive a list of chat ...
es1024's user avatar
  • 9,165
7 votes
19 answers
692 views

Read an analog clock

You are given the positions of the minute and hour hands of an analog clock as an angle of clockwise rotation from the top (12). So a hand pointing at 9 is at an angle if 270, and a hand pointing ...
ghosts_in_the_code's user avatar
20 votes
3 answers
452 views

Generate lazy microwave input

Related: Program my microwave oven and Generate lazy values. My colleague is so lazy that he doesn't even bother to move his finger when programming the microwave oven. (This is actually true!) Help ...
Adám's user avatar
  • 29.9k
3 votes
1 answer
330 views

What time is it again? [closed]

The Inspiration The Challenge I'm tired of seeing the same old-same old clock in my top-right-hand corner of my screen. It's time for a new clock. While the clock clock sated my lack of interesting ...
Addison Crump's user avatar
-3 votes
16 answers
733 views

Is the time linear?

I like patterns in time. My favorite is when the time lines up. For example, all of these line up: 3:45 12:34 23:45 3:21 6:54 This is because each digit in the ...
Seadrus's user avatar
  • 1,377
0 votes
0 answers
110 views

Is it a leap year? Use only assignments and arithmetic expressions [duplicate]

Write a program that outputs 1 when the year is a leap year, otherwise 0. You can use any programming language, but use only assignments and arithmetic expressions for the calculation. The Gregorian ...
Günter Hofer's user avatar
2 votes
1 answer
233 views

Convert string to time

This challenge is inspired by this other. The challenge Write a program or a function in any programming language that given as input a string representing a time in English (see below, for further ...
Bob's user avatar
  • 1,007
19 votes
8 answers
783 views

Convert the Time to a String

Problem One day, you boss walks up to you and tells you he needs to know the time. He still insists after you pointing at the clock directly above your head, and confesses he has a severe case of ...
Dennis van Gils's user avatar
16 votes
3 answers
464 views

Check work periods

Introduction Here in Germany the ruling on work times is very strict. If you work 6 or more hours a day, you have to take at least a 30 minute break. If you work 9 or more hours, you need to take a ...
Denker's user avatar
  • 6,831
12 votes
9 answers
1k views

Calculate the day number of the year

Seems like we do not have this one yet, so here we go: The Challenge Write a program or function that takes a date as input and outputs the day number of the year. You may not use any builtins for ...
Denker's user avatar
  • 6,831
17 votes
10 answers
715 views

Next public holiday

Australians love public holidays, and drinking. Yesterday, the 26th January, was Australia day, which is a public holiday. I was glad to not be at work yesterday, and eager to know the next time I get ...
Tas's user avatar
  • 593
10 votes
1 answer
2k views

Calculate the Lunar Phase

Introduction tl;dr In this challenge you have to calculate the moon's phase for a given date. This challenge is inspired by the game psycho social audiovisual experiment "Superbrothers: Sword & ...
insertusernamehere's user avatar
20 votes
6 answers
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 ...
DJMcMayhem's user avatar
  • 58.9k
19 votes
17 answers
2k views

Pi Day, Pi Minute, or Pi Second?

In this challenge you will need to determine whether it's Pi Day, Pi Minute, or Pi Second. Because Pi is irrational, it wants your code to be as short as possible. Examples No input is provided, ...
Downgoat's user avatar
  • 28.9k
11 votes
16 answers
790 views

Chinese Zodiac of the year

2015 was the year of the goat! In this challenge, you will figure out which animal represents the year. To avoid making this challenge to complex you won't need to calculate Chinese new year. Because ...
Downgoat's user avatar
  • 28.9k
17 votes
2 answers
953 views

Forgotten Realms date calculator

In an effort to level the playing field between languages with built-in date libraries and those without, let's work with a fictional calendar. The Forgotten Realms are a (the?) campaign setting for ...
Martin Ender's user avatar
1 vote
5 answers
131 views

Parrot User’s Delay [duplicate]

A simple code golf challenge similar to an already existing, but more complex one: Wait for user to press enter. Wait for user to press enter again. Print the elapsed time between the 1. and 2. Wait ...
Adám's user avatar
  • 29.9k
47 votes
9 answers
3k views

Read a date in xkcd notation

In his xkcd about the ISO 8601 standard date format Randall snuck in a rather curious alternative notation: The large numbers are all the digits that appear in the current date in their usual order, ...
Martin Ender's user avatar
26 votes
8 answers
1k views

Convert a date to xkcd notation

In his xkcd about the ISO 8601 standard date format Randall snuck in a rather curious alternative notation: The large numbers are all the digits that appear in the current date in their usual order, ...
Martin Ender's user avatar