Today is the CenterDay of the week of the next Feb 29thConvert calendar dates to week dates and vice versaWhat date is that again?ValiDate ISO 8601 by RXCreate a Winter Bash 2015 hat reminderHow many weeks?Beat Pure Regular Expressions at Validating ISO 8601 DatesToday in the YOLDASCII Calendar PlannerGet the date of the nth day of week in a given year and month

Were any external disk drives stacked vertically?

How could indestructible materials be used in power generation?

Watching something be written to a file live with tail

What does it mean to describe someone as a butt steak?

Assassin's bullet with mercury

90's TV series where a boy goes to another dimension through portal near power lines

Will google still index a page if I use a $_SESSION variable?

Python: return float 1.0 as int 1 but float 1.5 as float 1.5

Why doesn't H₄O²⁺ exist?

How to take photos in burst mode, without vibration?

Does casting Light, or a similar spell, have any effect when the caster is swallowed by a monster?

AES: Why is it a good practice to use only the first 16bytes of a hash for encryption?

Withdrawals from HSA

Has there ever been an airliner design involving reducing generator load by installing solar panels?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Brothers & sisters

What mechanic is there to disable a threat instead of killing it?

What is the word for reserving something for yourself before others do?

UK: Is there precedent for the governments e-petition site changing the direction of a government decision?

In Romance of the Three Kingdoms why do people still use bamboo sticks when papers are already invented?

Did Shadowfax go to Valinor?

Is it canonical bit space?

Why is consensus so controversial in Britain?

Combinations of multiple lists



Today is the Center


Day of the week of the next Feb 29thConvert calendar dates to week dates and vice versaWhat date is that again?ValiDate ISO 8601 by RXCreate a Winter Bash 2015 hat reminderHow many weeks?Beat Pure Regular Expressions at Validating ISO 8601 DatesToday in the YOLDASCII Calendar PlannerGet the date of the nth day of week in a given year and month













9












$begingroup$


Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the days of the week (i.e., Su Mo Tu We Th Fr Sa).



For example, given April 2 2019 as input, the output should be



Sa Su Mo Tu We Th Fr
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19


so that the given date is the exact middle of the calendar.



Given February 19 2020, output



Su Mo Tu We Th Fr Sa
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
1 2 3 4 5 6 7


For September 14 1752, show the following:



Mo Tu We Th Fr Sa Su
28 29 30 31 1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 1



  • Input and output can be given by any convenient method.

  • The input is guaranteed non-empty and valid (i.e., you'll never receive "" or Feb 31 etc.).

  • Assume Gregorian calendar for all dates.

  • Leap years must be accounted for.

  • Input dates will range from Jan 1 1600 to Dec 31 2500.

  • You can print it to STDOUT or return it as a function result.

  • Either a full program or a function are acceptable.

  • Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.









share|improve this question









$endgroup$
















    9












    $begingroup$


    Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the days of the week (i.e., Su Mo Tu We Th Fr Sa).



    For example, given April 2 2019 as input, the output should be



    Sa Su Mo Tu We Th Fr
    16 17 18 19 20 21 22
    23 24 25 26 27 28 29
    30 31 1 2 3 4 5
    6 7 8 9 10 11 12
    13 14 15 16 17 18 19


    so that the given date is the exact middle of the calendar.



    Given February 19 2020, output



    Su Mo Tu We Th Fr Sa
    2 3 4 5 6 7 8
    9 10 11 12 13 14 15
    16 17 18 19 20 21 22
    23 24 25 26 27 28 29
    1 2 3 4 5 6 7


    For September 14 1752, show the following:



    Mo Tu We Th Fr Sa Su
    28 29 30 31 1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 1



    • Input and output can be given by any convenient method.

    • The input is guaranteed non-empty and valid (i.e., you'll never receive "" or Feb 31 etc.).

    • Assume Gregorian calendar for all dates.

    • Leap years must be accounted for.

    • Input dates will range from Jan 1 1600 to Dec 31 2500.

    • You can print it to STDOUT or return it as a function result.

    • Either a full program or a function are acceptable.

    • Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.


    • Standard loopholes are forbidden.

    • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.









    share|improve this question









    $endgroup$














      9












      9








      9


      1



      $begingroup$


      Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the days of the week (i.e., Su Mo Tu We Th Fr Sa).



      For example, given April 2 2019 as input, the output should be



      Sa Su Mo Tu We Th Fr
      16 17 18 19 20 21 22
      23 24 25 26 27 28 29
      30 31 1 2 3 4 5
      6 7 8 9 10 11 12
      13 14 15 16 17 18 19


      so that the given date is the exact middle of the calendar.



      Given February 19 2020, output



      Su Mo Tu We Th Fr Sa
      2 3 4 5 6 7 8
      9 10 11 12 13 14 15
      16 17 18 19 20 21 22
      23 24 25 26 27 28 29
      1 2 3 4 5 6 7


      For September 14 1752, show the following:



      Mo Tu We Th Fr Sa Su
      28 29 30 31 1 2 3
      4 5 6 7 8 9 10
      11 12 13 14 15 16 17
      18 19 20 21 22 23 24
      25 26 27 28 29 30 1



      • Input and output can be given by any convenient method.

      • The input is guaranteed non-empty and valid (i.e., you'll never receive "" or Feb 31 etc.).

      • Assume Gregorian calendar for all dates.

      • Leap years must be accounted for.

      • Input dates will range from Jan 1 1600 to Dec 31 2500.

      • You can print it to STDOUT or return it as a function result.

      • Either a full program or a function are acceptable.

      • Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.


      • Standard loopholes are forbidden.

      • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.









      share|improve this question









      $endgroup$




      Given a date as input in any convenient format, output a calendar with that date as the exact center of a five-week window. The header of the calendar must include the two-letter abbreviations for the days of the week (i.e., Su Mo Tu We Th Fr Sa).



      For example, given April 2 2019 as input, the output should be



      Sa Su Mo Tu We Th Fr
      16 17 18 19 20 21 22
      23 24 25 26 27 28 29
      30 31 1 2 3 4 5
      6 7 8 9 10 11 12
      13 14 15 16 17 18 19


      so that the given date is the exact middle of the calendar.



      Given February 19 2020, output



      Su Mo Tu We Th Fr Sa
      2 3 4 5 6 7 8
      9 10 11 12 13 14 15
      16 17 18 19 20 21 22
      23 24 25 26 27 28 29
      1 2 3 4 5 6 7


      For September 14 1752, show the following:



      Mo Tu We Th Fr Sa Su
      28 29 30 31 1 2 3
      4 5 6 7 8 9 10
      11 12 13 14 15 16 17
      18 19 20 21 22 23 24
      25 26 27 28 29 30 1



      • Input and output can be given by any convenient method.

      • The input is guaranteed non-empty and valid (i.e., you'll never receive "" or Feb 31 etc.).

      • Assume Gregorian calendar for all dates.

      • Leap years must be accounted for.

      • Input dates will range from Jan 1 1600 to Dec 31 2500.

      • You can print it to STDOUT or return it as a function result.

      • Either a full program or a function are acceptable.

      • Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately.


      • Standard loopholes are forbidden.

      • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.






      code-golf ascii-art date






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      AdmBorkBorkAdmBorkBork

      27.7k466237




      27.7k466237




















          6 Answers
          6






          active

          oldest

          votes


















          1












          $begingroup$


          Wolfram Language (Mathematica), 131 bytes



          (s=#;Grid@Join[StringTake[#,2]&/@ToString/@(DayName[d[s,#]]&/@Range[-3,3]),Partition[Last@d[s,#]&/@Range[-17,17],7]])&
          d=DatePlus


          Try it online!



          I don't know why Grid doesn't work on TIO but this code outputs this



          enter image description here






          share|improve this answer









          $endgroup$












          • $begingroup$
            DayName[s~d~#]
            $endgroup$
            – DavidC
            1 hour ago


















          1












          $begingroup$


          JavaScript (Node.js), 205 bytes








          f=
          d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
          `

          <input type=date oninput=o.textContent=f(this.value)><pre id=o>





          Try it online! Takes input as a string in YYYY-MM-DD format, but the input field in the snippet displays your local date format.






          share|improve this answer









          $endgroup$












          • $begingroup$
            padStart(2) -> padStart(3), remove the space in the join string for -1 byte
            $endgroup$
            – Embodiment of Ignorance
            1 hour ago



















          0












          $begingroup$


          C# (Visual C# Interactive Compiler), 124 bytes





          n=>for(int i=-24;i<18;)Write($"(i<-17?$"n.AddDays(i):ddd".Remove(2,1):n.AddDays(i).Day+""),3"+((46+i++)%7<1?"n":""));


          Try it online!






          share|improve this answer









          $endgroup$




















            0












            $begingroup$


            R, 66 bytes





            function(d,g=format)write(c(g(d+-3:3,"%a"),g(d+-17:17,"%3d")),1,7)


            Try it online!



            Pads date numbers with leading 0s; takes input as a Date, which can be created by using as.Date("YYYY/MM/DD").



            Weirdly short for an R ascii-art answer...






            share|improve this answer









            $endgroup$




















              0












              $begingroup$

              JavaScript (ES6),  141  126 bytes



              Saved 15 bytes by borrowing .toUTCString().slice(0,2) from Neil's answer



              Takes input as a Date object.





              f=(d,n=0)=>n<42?(D=new Date(d-864e5*(24-n)),n<7?D.toUTCString().slice(0,2):(i=D.getDate())>9?i:' '+i)+`
              `[++n%7&&1]+f(d,n):''


              Try it online!






              share|improve this answer











              $endgroup$




















                0












                $begingroup$


                PHP, 197 189 bytes



                for($d=date_create($argn)->sub($i=new DateInterval(P17D)),$i->d=1;$x++<35;$d->add($i))if($x<8)$h.=substr($d->format(D),0,2).' ';$o.=str_pad($d->format(j),3,' ',2);echo wordwrap($h.$o,20);


                Try it online!



                Input is STDIN as a date string. Run with php -nF.



                $ echo April 2 2019|php -nF cal.php



                April 2 2019



                Sa Su Mo Tu We Th Fr 
                16 17 18 19 20 21 22
                23 24 25 26 27 28 29
                30 31 1 2 3 4 5
                6 7 8 9 10 11 12
                13 14 15 16 17 18 19


                February 19 2020



                Su Mo Tu We Th Fr Sa 
                2 3 4 5 6 7 8
                9 10 11 12 13 14 15
                16 17 18 19 20 21 22
                23 24 25 26 27 28 29
                1 2 3 4 5 6 7


                September 14 1752



                Mo Tu We Th Fr Sa Su 
                28 29 30 31 1 2 3
                4 5 6 7 8 9 10
                11 12 13 14 15 16 17
                18 19 20 21 22 23 24
                25 26 27 28 29 30 1





                share|improve this answer











                $endgroup$













                  Your Answer





                  StackExchange.ifUsing("editor", function ()
                  return StackExchange.using("mathjaxEditing", function ()
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                  );
                  );
                  , "mathjax-editing");

                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "200"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: false,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader:
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  ,
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182681%2ftoday-is-the-center%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  6 Answers
                  6






                  active

                  oldest

                  votes








                  6 Answers
                  6






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  1












                  $begingroup$


                  Wolfram Language (Mathematica), 131 bytes



                  (s=#;Grid@Join[StringTake[#,2]&/@ToString/@(DayName[d[s,#]]&/@Range[-3,3]),Partition[Last@d[s,#]&/@Range[-17,17],7]])&
                  d=DatePlus


                  Try it online!



                  I don't know why Grid doesn't work on TIO but this code outputs this



                  enter image description here






                  share|improve this answer









                  $endgroup$












                  • $begingroup$
                    DayName[s~d~#]
                    $endgroup$
                    – DavidC
                    1 hour ago















                  1












                  $begingroup$


                  Wolfram Language (Mathematica), 131 bytes



                  (s=#;Grid@Join[StringTake[#,2]&/@ToString/@(DayName[d[s,#]]&/@Range[-3,3]),Partition[Last@d[s,#]&/@Range[-17,17],7]])&
                  d=DatePlus


                  Try it online!



                  I don't know why Grid doesn't work on TIO but this code outputs this



                  enter image description here






                  share|improve this answer









                  $endgroup$












                  • $begingroup$
                    DayName[s~d~#]
                    $endgroup$
                    – DavidC
                    1 hour ago













                  1












                  1








                  1





                  $begingroup$


                  Wolfram Language (Mathematica), 131 bytes



                  (s=#;Grid@Join[StringTake[#,2]&/@ToString/@(DayName[d[s,#]]&/@Range[-3,3]),Partition[Last@d[s,#]&/@Range[-17,17],7]])&
                  d=DatePlus


                  Try it online!



                  I don't know why Grid doesn't work on TIO but this code outputs this



                  enter image description here






                  share|improve this answer









                  $endgroup$




                  Wolfram Language (Mathematica), 131 bytes



                  (s=#;Grid@Join[StringTake[#,2]&/@ToString/@(DayName[d[s,#]]&/@Range[-3,3]),Partition[Last@d[s,#]&/@Range[-17,17],7]])&
                  d=DatePlus


                  Try it online!



                  I don't know why Grid doesn't work on TIO but this code outputs this



                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 3 hours ago









                  J42161217J42161217

                  13.8k21253




                  13.8k21253











                  • $begingroup$
                    DayName[s~d~#]
                    $endgroup$
                    – DavidC
                    1 hour ago
















                  • $begingroup$
                    DayName[s~d~#]
                    $endgroup$
                    – DavidC
                    1 hour ago















                  $begingroup$
                  DayName[s~d~#]
                  $endgroup$
                  – DavidC
                  1 hour ago




                  $begingroup$
                  DayName[s~d~#]
                  $endgroup$
                  – DavidC
                  1 hour ago











                  1












                  $begingroup$


                  JavaScript (Node.js), 205 bytes








                  f=
                  d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
                  `

                  <input type=date oninput=o.textContent=f(this.value)><pre id=o>





                  Try it online! Takes input as a string in YYYY-MM-DD format, but the input field in the snippet displays your local date format.






                  share|improve this answer









                  $endgroup$












                  • $begingroup$
                    padStart(2) -> padStart(3), remove the space in the join string for -1 byte
                    $endgroup$
                    – Embodiment of Ignorance
                    1 hour ago
















                  1












                  $begingroup$


                  JavaScript (Node.js), 205 bytes








                  f=
                  d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
                  `

                  <input type=date oninput=o.textContent=f(this.value)><pre id=o>





                  Try it online! Takes input as a string in YYYY-MM-DD format, but the input field in the snippet displays your local date format.






                  share|improve this answer









                  $endgroup$












                  • $begingroup$
                    padStart(2) -> padStart(3), remove the space in the join string for -1 byte
                    $endgroup$
                    – Embodiment of Ignorance
                    1 hour ago














                  1












                  1








                  1





                  $begingroup$


                  JavaScript (Node.js), 205 bytes








                  f=
                  d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
                  `

                  <input type=date oninput=o.textContent=f(this.value)><pre id=o>





                  Try it online! Takes input as a string in YYYY-MM-DD format, but the input field in the snippet displays your local date format.






                  share|improve this answer









                  $endgroup$




                  JavaScript (Node.js), 205 bytes








                  f=
                  d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
                  `

                  <input type=date oninput=o.textContent=f(this.value)><pre id=o>





                  Try it online! Takes input as a string in YYYY-MM-DD format, but the input field in the snippet displays your local date format.






                  f=
                  d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
                  `

                  <input type=date oninput=o.textContent=f(this.value)><pre id=o>





                  f=
                  d=>[...`012345`].map(r=>[...`0123456`].map(c=>`$new Date(d+864e5*(+c+r*7-24))[+r?`getUTCDate`:`toUTCString`]()`.slice(0,2).padStart(2)).join` `,d=new Date(d.slice(0,2)%4+20+d.slice(2)).getTime()).join`
                  `

                  <input type=date oninput=o.textContent=f(this.value)><pre id=o>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  NeilNeil

                  82.5k745179




                  82.5k745179











                  • $begingroup$
                    padStart(2) -> padStart(3), remove the space in the join string for -1 byte
                    $endgroup$
                    – Embodiment of Ignorance
                    1 hour ago

















                  • $begingroup$
                    padStart(2) -> padStart(3), remove the space in the join string for -1 byte
                    $endgroup$
                    – Embodiment of Ignorance
                    1 hour ago
















                  $begingroup$
                  padStart(2) -> padStart(3), remove the space in the join string for -1 byte
                  $endgroup$
                  – Embodiment of Ignorance
                  1 hour ago





                  $begingroup$
                  padStart(2) -> padStart(3), remove the space in the join string for -1 byte
                  $endgroup$
                  – Embodiment of Ignorance
                  1 hour ago












                  0












                  $begingroup$


                  C# (Visual C# Interactive Compiler), 124 bytes





                  n=>for(int i=-24;i<18;)Write($"(i<-17?$"n.AddDays(i):ddd".Remove(2,1):n.AddDays(i).Day+""),3"+((46+i++)%7<1?"n":""));


                  Try it online!






                  share|improve this answer









                  $endgroup$

















                    0












                    $begingroup$


                    C# (Visual C# Interactive Compiler), 124 bytes





                    n=>for(int i=-24;i<18;)Write($"(i<-17?$"n.AddDays(i):ddd".Remove(2,1):n.AddDays(i).Day+""),3"+((46+i++)%7<1?"n":""));


                    Try it online!






                    share|improve this answer









                    $endgroup$















                      0












                      0








                      0





                      $begingroup$


                      C# (Visual C# Interactive Compiler), 124 bytes





                      n=>for(int i=-24;i<18;)Write($"(i<-17?$"n.AddDays(i):ddd".Remove(2,1):n.AddDays(i).Day+""),3"+((46+i++)%7<1?"n":""));


                      Try it online!






                      share|improve this answer









                      $endgroup$




                      C# (Visual C# Interactive Compiler), 124 bytes





                      n=>for(int i=-24;i<18;)Write($"(i<-17?$"n.AddDays(i):ddd".Remove(2,1):n.AddDays(i).Day+""),3"+((46+i++)%7<1?"n":""));


                      Try it online!







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 3 hours ago









                      Embodiment of IgnoranceEmbodiment of Ignorance

                      2,718126




                      2,718126





















                          0












                          $begingroup$


                          R, 66 bytes





                          function(d,g=format)write(c(g(d+-3:3,"%a"),g(d+-17:17,"%3d")),1,7)


                          Try it online!



                          Pads date numbers with leading 0s; takes input as a Date, which can be created by using as.Date("YYYY/MM/DD").



                          Weirdly short for an R ascii-art answer...






                          share|improve this answer









                          $endgroup$

















                            0












                            $begingroup$


                            R, 66 bytes





                            function(d,g=format)write(c(g(d+-3:3,"%a"),g(d+-17:17,"%3d")),1,7)


                            Try it online!



                            Pads date numbers with leading 0s; takes input as a Date, which can be created by using as.Date("YYYY/MM/DD").



                            Weirdly short for an R ascii-art answer...






                            share|improve this answer









                            $endgroup$















                              0












                              0








                              0





                              $begingroup$


                              R, 66 bytes





                              function(d,g=format)write(c(g(d+-3:3,"%a"),g(d+-17:17,"%3d")),1,7)


                              Try it online!



                              Pads date numbers with leading 0s; takes input as a Date, which can be created by using as.Date("YYYY/MM/DD").



                              Weirdly short for an R ascii-art answer...






                              share|improve this answer









                              $endgroup$




                              R, 66 bytes





                              function(d,g=format)write(c(g(d+-3:3,"%a"),g(d+-17:17,"%3d")),1,7)


                              Try it online!



                              Pads date numbers with leading 0s; takes input as a Date, which can be created by using as.Date("YYYY/MM/DD").



                              Weirdly short for an R ascii-art answer...







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 1 hour ago









                              GiuseppeGiuseppe

                              17.5k31152




                              17.5k31152





















                                  0












                                  $begingroup$

                                  JavaScript (ES6),  141  126 bytes



                                  Saved 15 bytes by borrowing .toUTCString().slice(0,2) from Neil's answer



                                  Takes input as a Date object.





                                  f=(d,n=0)=>n<42?(D=new Date(d-864e5*(24-n)),n<7?D.toUTCString().slice(0,2):(i=D.getDate())>9?i:' '+i)+`
                                  `[++n%7&&1]+f(d,n):''


                                  Try it online!






                                  share|improve this answer











                                  $endgroup$

















                                    0












                                    $begingroup$

                                    JavaScript (ES6),  141  126 bytes



                                    Saved 15 bytes by borrowing .toUTCString().slice(0,2) from Neil's answer



                                    Takes input as a Date object.





                                    f=(d,n=0)=>n<42?(D=new Date(d-864e5*(24-n)),n<7?D.toUTCString().slice(0,2):(i=D.getDate())>9?i:' '+i)+`
                                    `[++n%7&&1]+f(d,n):''


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$















                                      0












                                      0








                                      0





                                      $begingroup$

                                      JavaScript (ES6),  141  126 bytes



                                      Saved 15 bytes by borrowing .toUTCString().slice(0,2) from Neil's answer



                                      Takes input as a Date object.





                                      f=(d,n=0)=>n<42?(D=new Date(d-864e5*(24-n)),n<7?D.toUTCString().slice(0,2):(i=D.getDate())>9?i:' '+i)+`
                                      `[++n%7&&1]+f(d,n):''


                                      Try it online!






                                      share|improve this answer











                                      $endgroup$



                                      JavaScript (ES6),  141  126 bytes



                                      Saved 15 bytes by borrowing .toUTCString().slice(0,2) from Neil's answer



                                      Takes input as a Date object.





                                      f=(d,n=0)=>n<42?(D=new Date(d-864e5*(24-n)),n<7?D.toUTCString().slice(0,2):(i=D.getDate())>9?i:' '+i)+`
                                      `[++n%7&&1]+f(d,n):''


                                      Try it online!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 15 mins ago

























                                      answered 25 mins ago









                                      ArnauldArnauld

                                      80.3k797332




                                      80.3k797332





















                                          0












                                          $begingroup$


                                          PHP, 197 189 bytes



                                          for($d=date_create($argn)->sub($i=new DateInterval(P17D)),$i->d=1;$x++<35;$d->add($i))if($x<8)$h.=substr($d->format(D),0,2).' ';$o.=str_pad($d->format(j),3,' ',2);echo wordwrap($h.$o,20);


                                          Try it online!



                                          Input is STDIN as a date string. Run with php -nF.



                                          $ echo April 2 2019|php -nF cal.php



                                          April 2 2019



                                          Sa Su Mo Tu We Th Fr 
                                          16 17 18 19 20 21 22
                                          23 24 25 26 27 28 29
                                          30 31 1 2 3 4 5
                                          6 7 8 9 10 11 12
                                          13 14 15 16 17 18 19


                                          February 19 2020



                                          Su Mo Tu We Th Fr Sa 
                                          2 3 4 5 6 7 8
                                          9 10 11 12 13 14 15
                                          16 17 18 19 20 21 22
                                          23 24 25 26 27 28 29
                                          1 2 3 4 5 6 7


                                          September 14 1752



                                          Mo Tu We Th Fr Sa Su 
                                          28 29 30 31 1 2 3
                                          4 5 6 7 8 9 10
                                          11 12 13 14 15 16 17
                                          18 19 20 21 22 23 24
                                          25 26 27 28 29 30 1





                                          share|improve this answer











                                          $endgroup$

















                                            0












                                            $begingroup$


                                            PHP, 197 189 bytes



                                            for($d=date_create($argn)->sub($i=new DateInterval(P17D)),$i->d=1;$x++<35;$d->add($i))if($x<8)$h.=substr($d->format(D),0,2).' ';$o.=str_pad($d->format(j),3,' ',2);echo wordwrap($h.$o,20);


                                            Try it online!



                                            Input is STDIN as a date string. Run with php -nF.



                                            $ echo April 2 2019|php -nF cal.php



                                            April 2 2019



                                            Sa Su Mo Tu We Th Fr 
                                            16 17 18 19 20 21 22
                                            23 24 25 26 27 28 29
                                            30 31 1 2 3 4 5
                                            6 7 8 9 10 11 12
                                            13 14 15 16 17 18 19


                                            February 19 2020



                                            Su Mo Tu We Th Fr Sa 
                                            2 3 4 5 6 7 8
                                            9 10 11 12 13 14 15
                                            16 17 18 19 20 21 22
                                            23 24 25 26 27 28 29
                                            1 2 3 4 5 6 7


                                            September 14 1752



                                            Mo Tu We Th Fr Sa Su 
                                            28 29 30 31 1 2 3
                                            4 5 6 7 8 9 10
                                            11 12 13 14 15 16 17
                                            18 19 20 21 22 23 24
                                            25 26 27 28 29 30 1





                                            share|improve this answer











                                            $endgroup$















                                              0












                                              0








                                              0





                                              $begingroup$


                                              PHP, 197 189 bytes



                                              for($d=date_create($argn)->sub($i=new DateInterval(P17D)),$i->d=1;$x++<35;$d->add($i))if($x<8)$h.=substr($d->format(D),0,2).' ';$o.=str_pad($d->format(j),3,' ',2);echo wordwrap($h.$o,20);


                                              Try it online!



                                              Input is STDIN as a date string. Run with php -nF.



                                              $ echo April 2 2019|php -nF cal.php



                                              April 2 2019



                                              Sa Su Mo Tu We Th Fr 
                                              16 17 18 19 20 21 22
                                              23 24 25 26 27 28 29
                                              30 31 1 2 3 4 5
                                              6 7 8 9 10 11 12
                                              13 14 15 16 17 18 19


                                              February 19 2020



                                              Su Mo Tu We Th Fr Sa 
                                              2 3 4 5 6 7 8
                                              9 10 11 12 13 14 15
                                              16 17 18 19 20 21 22
                                              23 24 25 26 27 28 29
                                              1 2 3 4 5 6 7


                                              September 14 1752



                                              Mo Tu We Th Fr Sa Su 
                                              28 29 30 31 1 2 3
                                              4 5 6 7 8 9 10
                                              11 12 13 14 15 16 17
                                              18 19 20 21 22 23 24
                                              25 26 27 28 29 30 1





                                              share|improve this answer











                                              $endgroup$




                                              PHP, 197 189 bytes



                                              for($d=date_create($argn)->sub($i=new DateInterval(P17D)),$i->d=1;$x++<35;$d->add($i))if($x<8)$h.=substr($d->format(D),0,2).' ';$o.=str_pad($d->format(j),3,' ',2);echo wordwrap($h.$o,20);


                                              Try it online!



                                              Input is STDIN as a date string. Run with php -nF.



                                              $ echo April 2 2019|php -nF cal.php



                                              April 2 2019



                                              Sa Su Mo Tu We Th Fr 
                                              16 17 18 19 20 21 22
                                              23 24 25 26 27 28 29
                                              30 31 1 2 3 4 5
                                              6 7 8 9 10 11 12
                                              13 14 15 16 17 18 19


                                              February 19 2020



                                              Su Mo Tu We Th Fr Sa 
                                              2 3 4 5 6 7 8
                                              9 10 11 12 13 14 15
                                              16 17 18 19 20 21 22
                                              23 24 25 26 27 28 29
                                              1 2 3 4 5 6 7


                                              September 14 1752



                                              Mo Tu We Th Fr Sa Su 
                                              28 29 30 31 1 2 3
                                              4 5 6 7 8 9 10
                                              11 12 13 14 15 16 17
                                              18 19 20 21 22 23 24
                                              25 26 27 28 29 30 1






                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited 4 mins ago

























                                              answered 2 hours ago









                                              gwaughgwaugh

                                              1,998517




                                              1,998517



























                                                  draft saved

                                                  draft discarded
















































                                                  If this is an answer to a challenge…



                                                  • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                  • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                    Explanations of your answer make it more interesting to read and are very much encouraged.


                                                  • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                  More generally…



                                                  • …Please make sure to answer the question and provide sufficient detail.


                                                  • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182681%2ftoday-is-the-center%23new-answer', 'question_page');

                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

                                                  Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

                                                  Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar