6
Given a date, output the X and Y position of the current day of the date on a digital calendar. The digital calendar is sort of the calendar that gets shown when you click on your computers clock (at least on windows), and it looks something like this:
If we assume that the given date is 25.09.2017, the result would be (2,5)
, because the 25th day of the 9th month of this year is in the second column and fifth row.
Note that if the date would be something like 29.08.2017, we couldn't use the calendar from above, but a new one for August. The gray-ish numbers are simply there to fill the gaps until the day that the month actually starts.
Input
A date, in any reasonable format.
Output
The point or coordinates that the day of the given date lies at, in its respective calendar. These should be 1-indexed.
Rules
- This is code-golf, the shortest code in any language wins.
- Standard loopholes are forbidden.
Additional Notes
The first column of the calendar will always be Sunday.
Here are the digital calendars from January and September 2017:
Test Cases
Input: 06.02.2018 (DD.MM.YYYY)
or 2018.02.06 (YYYY.MM.DD)
Output: (3,2)
Input: 12.11.1982 (DD.MM.YYYY)
or 1982.11.12 (YYYY.MM.DD)
Output: (6,2)
Input: 01.01.2030 (DD.MM.YYYY)
or 2030.01.01 (YYYY.MM.DD)
Output: (3,1)
Input: 13.06.3017 (DD.MM.YYYY)
or 3017.06.13 (YYYY.MM.DD)
Output: (6,3)
Your "September 2017" calendar seems to be a bit off... – Erik the Outgolfer – 2017-09-30T14:41:56.070
@EriktheOutgolfer My bad, fixing it. – Ian H. – 2017-09-30T14:42:59.530
5I recommend providing your example test-cases in the yyyy-mm-dd format to account for an international audience. – wizzwizz4 – 2017-09-30T14:46:27.970
Why would 2017-09-25 return
(1,5)
instead of(2,5)
if the output is 1-indexed starting on Sunday? – LegionMammal978 – 2017-09-30T15:15:34.6372You say 1-indexed coordinates, first column is Sunday. So Sunday is column 1, Monday is coumn 2. Yet your example says Monday is column 1. Please clarify. Voting to close as unclear until resolved – Luis Mendo – 2017-09-30T15:23:27.467
Could we have test cases for days distant such as year 400 or year 3017? – fireflame241 – 2017-09-30T15:25:03.250
@LuisMendo My bad, forgot to change that. Fixed it now. – Ian H. – 2017-09-30T15:40:17.720
@fireflame241 Added one for 13.06.3017. – Ian H. – 2017-09-30T15:45:22.080
I apologise for the incorrect outputs for the test cases, it seems like i had a bug in the program i wrote to calculate them. They should be fine now. – Ian H. – 2017-09-30T15:53:14.113
i think that the last case should be (6,3) - becuase the 13th in that month is friday - or js date is incorrect... – DanielIndie – 2017-09-30T16:25:17.027
@IanH. If you use the Sandbox you can fix such things before posting on main. – Erik the Outgolfer – 2017-09-30T16:40:51.097
2@EriktheOutgolfer This post was sandboxed. – Ian H. – 2017-09-30T16:49:45.260
@IanH. Yeah the sandbox isn't 100% great either. – Erik the Outgolfer – 2017-09-30T16:52:47.727
1@EriktheOutgolfer I always sandbox my post, simply because I'm not sure whether people will understand my challenge, although the biggest errors almost never get found in the sandbox ... – Ian H. – 2017-09-30T17:10:36.950
1Is there any limit in the dates? More precisely - should we account for Gregorian vs. Julian Calendar? – Grzegorz Oledzki – 2017-09-30T18:22:16.767
A bit unclear, but I assume that
any reasonable format
means that we can chose the input format, as long as it is reasonable. – Titus – 2017-09-30T18:29:06.910@GrzegorzOledzki No it's not neccessary. Maybe just specify which calendar you use in your code. – Ian H. – 2017-09-30T18:48:05.140