Skip to main content

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
56 votes
37 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 ...
81 votes
40 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 ...
25 votes
36 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: ...
5 votes
4 answers
791 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 ...
69 votes
70 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. ...
40 votes
29 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 ...
17 votes
24 answers
2k 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. ...
101 votes
59 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 ...
18 votes
21 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 ...
47 votes
79 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: ...
7 votes
14 answers
4k 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 ...
15 votes
11 answers
987 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 ...
14 votes
7 answers
597 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: ...
9 votes
18 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 ...
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 ...
72 votes
21 answers
7k 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....
24 votes
45 answers
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 ...
79 votes
43 answers
7k 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 ...
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 ...
16 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): ...
67 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 ...
53 votes
53 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 ...
11 votes
3 answers
616 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 ...
15 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 ...
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 ...
8 votes
9 answers
678 views

Output: Calendar Month (without native calendar generating functions)

Upon receiving month and year in YYYYMM format, generate output of the corresponding calendar month for that year. For example the input 201312 should generate ...
7 votes
6 answers
386 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 ...
31 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 ...
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 ...
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 ...
19 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
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>...
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....
29 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 ...
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 ...
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
3k 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 ...
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
308 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
275 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-...

1
2 3 4 5 6