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
12 votes
19 answers
1k views

Percentage of work days in a month

Given a year and a month, find out the percentage of work days in said month. Work days are Monday through Friday with no regard to holidays or other special things. The Gregorian calendar is used. ...
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 ...
29 votes
37 answers
8k views

How many friday the 13th in a year?

Your challenge is to write a program which, given a year, outputs the number of "Friday 13ths" in it. Rules & Details: You can take input via STDIN, or as an ...
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 ...
99 votes
54 answers
18k views

Sleep for 1000 years

Some sleep commands implement a delay of an integer number of seconds. However, 2Β³Β² seconds is only about 100 years. Bug! What if you need a larger delay? Make a ...
66 votes
14 answers
5k views

Print a word clock

Since I saw the first one a few years ago, I always was subjugated by this kind of word clock where the time is actually spelled out by words being lit up or not into a meaningful sentence. The text ...
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 ...
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 ...
12 votes
20 answers
3k views

Draw a BCD Binary clock

Create a BCD binary clock in ASCII. As implied, it shall display time in six columns of dots: (source: Wikimedia Commons) Each column is a binary-coded digit, reading hours, minutes and seconds ...
27 votes
11 answers
3k views

Return the clock emoji closest to the current time when run

I can have a large if/else condition for each 30 minutes but I'm looking for more math and Unicode based solution. Here are clock emojis: πŸ•πŸ•‘πŸ•’πŸ•“πŸ•”πŸ••πŸ•–πŸ•—πŸ•˜πŸ•™πŸ•šπŸ•›πŸ•œοΏ½...
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 ...
46 votes
78 answers
10k 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: ...
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 ...
20 votes
50 answers
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: ...
11 votes
6 answers
999 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>...
38 votes
34 answers
5k views

Advance Happy New Year, 2016!

Your input will be a integer between 1970 and 2090 (inclusive), representing a year. Your program should output the next year on which New Years Day falls on the same day of the week as the input year....
28 votes
36 answers
3k views

Days in indexed month

This simple challenge is very similar to this one: How many days in a month? The only difference is you yield the number of days in a month given the index of the month instead of its name. The ...
35 votes
38 answers
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 ...
23 votes
43 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 ...
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, ...
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 ...
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. ...
35 votes
67 answers
4k views

It's [current year] already, folks, go home

On most new-years challenges when it is currently not the corresponding year of the challenge, It says this in the front. It's [current year] already, folks, go home. You have to output this text ...
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 ...
29 votes
68 answers
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 ...
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 ...
66 votes
50 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 ...
45 votes
94 answers
5k views

Output the Current Time

Challenge You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means: It must be in 24-hour or AM/PM format. If it is the ...
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, ...
8 votes
2 answers
303 views

Output ISO8601 date

The Task Given the positive value of unix timestamp output any of two valid ISO 8601 time formats: YYYY-MM-DDTHH:mm:SS or, alternatively, ...
1 vote
4 answers
229 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 (...
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 ...
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-...
13 votes
7 answers
1k views

How long until this date?

The idea is this: Write a function to print the length of time from now/today's date (at the time the function is called) until a date supplied as an argument. Assumptions: Input date will always be ...
19 votes
15 answers
3k views

The Time Traveler

The shortest code to generate the correct times on the clocks wins. You are a seasoned time traveler and have been known to stop at many planets during your journies. Each planet rotates at a ...
18 votes
3 answers
808 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 ...
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: ...
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 ...
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 ...
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 ...
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 ...
12 votes
7 answers
1k views

What's the day today (or other dates)?

Task Write a program or a function that calculates a week-day name of a date which a user inputs. Input & Output Input is a string, YYYYMMDD. Example of ...
25 votes
37 answers
4k views

It's time for a clock challenge!

I'd like you to build me a clock that displays time in this format: 18 ---------- 19 -------------------------------------------------- This displays '18:10'. The ...
15 votes
41 answers
3k views

Pause twice as long

Your challenge is to print the input, wait any amount of time, print the input, wait twice the time you initially waited, print the input again, and so on. The initial delay must be less than 1 hour, ...
30 votes
26 answers
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 ...
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 ...
8 votes
10 answers
688 views

These Days Work for Me

Background You're an attractive code golfer and quite a few people are asking you out. You don't have time to think about which days exactly you're available, so you decide to create a function the ...
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 ...
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 ...
27 votes
9 answers
672 views

Track listings to time tables

Introduction Don't you hate it when someone uploads an album you like to YouTube, but the description only contains a track listing? Like this: ...

1
2 3 4 5 6