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
24
votes
21
answers
3k
views
When was the last time the date was divisible by n?
A date can be represented by an unsigned integer as such: YYYYMMDD. What you need to do, is write the shortest program or function that figures out the most recent date whose number was divisible by a ...
13
votes
8
answers
2k
views
What is your star-sign?
Write a program that takes a birth date (month and day-of-month) as input and outputs the corresponding sign, element and quality of the western zodiac. For the purposes of this challenge, these are ...
25
votes
5
answers
5k
views
Shortest expression for {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}
Given list of integers {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}.
For those who interested these numbers are used in weekday calculation.
Weekday = ...
103
votes
14
answers
11k
views
Has my milk expired?
Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of ...
14
votes
7
answers
1k
views
Minimalist Hex Clock
Your challenge is to create a clock that displays the time as a hex number, and the background color as the hex color code of the time.
Requirements: No input. In the center of your output you ...
7
votes
2
answers
694
views
Thwarting the Fry King
Setting
The Fry King is a small criminal mastermind from the western european nation of Belgium, more specifically Flanders. He has acquired every single fastfood restaurant in a large part of ...
-5
votes
1
answer
218
views
Longest code to reduce words [closed]
Write a code in your favorite language which reduces words To first three characters.
...
6
votes
7
answers
891
views
Print the time in a digital watch [duplicate]
Write a program that prints the current time in a digital watch.
Rules:
The program must use the local timezone.
Time is expressed between 00:00 to 23:59 (with only hours and minutes).
The program ...
13
votes
10
answers
1k
views
Find all times that follow a pattern
Your job is write a program that prints all times (in the format HH:MM, 24 hours) that follow any of the following patterns:
Hours equal to minutes, e.g. 22:22,01:01
Hours equal to reverse minutes, e....
11
votes
6
answers
5k
views
Calculate Chinese Zodiac sign
Given that the Chinese New Year is coming, here is a challenge to calculate the Chinese Zodiac, element and Taijitu for a given date.
The input should be a date:
...
9
votes
4
answers
657
views
Find the next "interesting" time
I happened to glance at my watch today at exactly 11:11:11 (and today is 1/11; too bad it's not 2011), and that got me thinking: I know! I should make a code golf question out of this! I'm a dork.
...
0
votes
2
answers
143
views
Party all week end for my birthday? [duplicate]
Knowing a given date (11/28/1973), and supposing I will die when I'm 99, what are the years when my birthday will be a thursday so that I will be able to party all ...
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 ...
7
votes
8
answers
599
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 ...
2
votes
5
answers
230
views
Relative dates in words
Given a specific date, have the code output a relative reference:
If the date entered is ahead of the current date, express as "x days from now" or "x weeks, y days from now", or "x years, y weeks, z ...
15
votes
9
answers
2k
views
Calculate the date of Easter
Your function or program should take a year as input and return (or print) the date (in the Gregorian calendar) of that years Easter (not the Eastern Orthodox Easter). The date returned should be ...
-1
votes
1
answer
345
views
Merge working time periods
You have an array of working time period pairs (from, till) received from user input and written according 24-hour clock format convention.
You have to merge these periods if the intersect each ...
9
votes
9
answers
699
views
Working Week Completion
I work a standard nine to five. Monday through Friday. I take a half hour for lunch from 12:30 to 13:00.
Write me a program which, when run, calculates the percentage of the working week that I have ...
5
votes
10
answers
1k
views
Day of the week for a given date of this year. Do not use any date tools [duplicate]
Please write a program that takes as input two numbers 'day of the month' and 'month number' for any day of this year (2012) and outputs day of the week.
Examples:
...
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 ...
8
votes
4
answers
852
views
Convert __DATE__-style string to sortable string
Goal is to write the shortest possible C89 and C99-compliant single-module C program which will compute and print out a single-line string whose sort order will correspond with the date given by 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 ...
4
votes
5
answers
3k
views
C: Output "tomorrow's date"
I'm a code golf novice, but I'm eager to give it a go.
My challenge is: Write the shortest program in C which takes in a date D as input and outputs the date ...
12
votes
6
answers
1k
views
Compute the difference between two days.
Another date-manipulating problem :P
Task
Write a program or a function that calculates the difference between two dates given by a user.
Input & Output
Similar to the previous one, inputs ...
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 ...
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 ...
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
...
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
12
answers
1k
views
Day of the week of the next Feb 29th
Write a function which takes a date and returns the day of the week of the next February 29th after that date.
The input is a string in the ISO Extended format: YYYY-MM-DD (e.g. May 27th, 2010 would ...
15
votes
24
answers
2k
views
Next Friday the 13th
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?
Must be an complete functioning program (not just a function/subroutine)
Must print out date ...