<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elayaraja Subramanian</title>
    <description>The latest articles on DEV Community by Elayaraja Subramanian (@elayarajasubramanian).</description>
    <link>https://dev.to/elayarajasubramanian</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F305867%2F03b24e55-d604-4373-89c0-35b9a202de3d.png</url>
      <title>DEV Community: Elayaraja Subramanian</title>
      <link>https://dev.to/elayarajasubramanian</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elayarajasubramanian"/>
    <language>en</language>
    <item>
      <title>Need help to show a calendar on a weekly basis</title>
      <dc:creator>Elayaraja Subramanian</dc:creator>
      <pubDate>Mon, 01 Feb 2021 06:40:39 +0000</pubDate>
      <link>https://dev.to/elayarajasubramanian/need-help-to-show-a-calendar-on-a-weekly-basis-lo7</link>
      <guid>https://dev.to/elayarajasubramanian/need-help-to-show-a-calendar-on-a-weekly-basis-lo7</guid>
      <description>&lt;p&gt;Hi techies,&lt;/p&gt;

&lt;p&gt;I am working on a project which needs a calendar of events to be shown only for a week. Also, there will be buttons to navigate to previous weeks and next weeks. I have attached the javascript code which I wrote code for the monthly view (without any events attached to it). I need to make a few tweaks to the below code but since I am a beginner to the front-end devlopment, I can't able to fulfill the requirement.&lt;/p&gt;

&lt;p&gt;JS Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const date = new Date();
const loadCalendar = () =&amp;gt; {
    date.setDate(1);
    const monthDays = document.querySelector('.dashboard__calendar-dates');
    const lastDay = new Date(date.getFullYear(), date.getMonth()+1,0).getDate();
    const prevDay = new Date(date.getFullYear(), date.getMonth(),0).getDate();
    const firstDayIndex = date.getDay();
    const lastDayIndex = new Date(date.getFullYear(), date.getMonth()+1,0).getDay();
    const nextDays = 7 - lastDayIndex-1;
    const months = [
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
    ];
    const daysName = [
        "Sun",
        "Mon",
        "Tue",
        "Wed",
        "Thu",
        "Fri",
        "Sat"
    ];
    const dayNumber = new Date();
    document.querySelector('.dashboard__calendar-h4-edit').innerHTML = months[date.getMonth()]+` &amp;lt;span id="year"&amp;gt;`+date.getFullYear()+`&amp;lt;span&amp;gt;`;
    let days = "";
    for (let x = firstDayIndex; x&amp;gt;0; x--){
        days += `&amp;lt;p id="dashboard__calendar-prevdays"&amp;gt;${prevDay-x+1}&amp;lt;/p&amp;gt;`;
    }
    for (let i=1; i&amp;lt;=lastDay; i++){
        if(i===new Date().getDate()&amp;amp;&amp;amp; date.getMonth()=== new Date().getMonth()){
            days += `&amp;lt;p class="active"&amp;gt;${i}&amp;lt;/p&amp;gt;`;
        }else{
            days += `&amp;lt;p&amp;gt;${i}&amp;lt;/p&amp;gt;`;
            monthDays.innerHTML = days;
        } 
    }
    for (let j=1; j&amp;lt;=nextDays; j++){
        days += `&amp;lt;p id="dashboard__calendar-nextdays"&amp;gt;${j}&amp;lt;/p&amp;gt;`;
        monthDays.innerHTML = days;
    }

}
loadCalendar();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="dashboard__calendar-edit"&amp;gt;
    &amp;lt;div class="dashboard__calendar-container"&amp;gt;
        &amp;lt;div class="dashboard__calendar-layout"&amp;gt;
            &amp;lt;div class="dashboard__calendar-top"&amp;gt;
                                                &amp;lt;h4 class="dashboard__calendar-h4-edit"&amp;gt;&amp;lt;/h4&amp;gt;
                                                &amp;lt;div class="dashboard__calendar-buttons"&amp;gt;
                                                    &amp;lt;a href="#" class="dashboard__calendar-prev-btn"&amp;gt;&amp;lt;i class="fas fa-chevron-left"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;
                                                    &amp;lt;a href="#" class="dashboard__calendar-next-btn"&amp;gt;&amp;lt;i class="fas fa-chevron-right"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;
                                                &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
                                &amp;lt;div class="dashboard__calendar-data"&amp;gt;
                                                &amp;lt;div class="dashboard__calendar-days dashboard__calendar-daysname"&amp;gt;
                                                    &amp;lt;p&amp;gt;Sun&amp;lt;/p&amp;gt;
                                                    &amp;lt;p&amp;gt;Mon&amp;lt;/p&amp;gt;
                                                    &amp;lt;p&amp;gt;Tue&amp;lt;/p&amp;gt;
                                                    &amp;lt;p&amp;gt;Wed&amp;lt;/p&amp;gt;
                                                    &amp;lt;p&amp;gt;Thu&amp;lt;/p&amp;gt;
                                                    &amp;lt;p&amp;gt;Fri&amp;lt;/p&amp;gt;
                                                    &amp;lt;p&amp;gt;Sat&amp;lt;/p&amp;gt;
                                                &amp;lt;/div&amp;gt;
                                                &amp;lt;div class="dashboard__calendar-days dashboard__calendar-dates"&amp;gt;
                                                &amp;lt;/div&amp;gt;
                                                &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
     &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'd appreciate any help.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
