Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start calendar with current month #18

Closed
krizajb opened this issue Apr 24, 2016 · 9 comments
Closed

Start calendar with current month #18

krizajb opened this issue Apr 24, 2016 · 9 comments

Comments

@krizajb
Copy link

krizajb commented Apr 24, 2016

I didn't find an option to display calendar (12 months) starting with specific Date, current month.

@krizajb
Copy link
Author

krizajb commented Apr 24, 2016

I made a simple workaround by displaying two calendars, first displays current year months and second months of next year. In next step I have simply hidden the past months of current year and hidden the months of next year. All accepted months from next year are detached and appended to first calendar to support responsiveness.

  var currentMonth = new Date().getMonth();

  $('#first_calendar .month-container').each(function(idx, el){
    if (idx < currentMonth) {
      $(this).css("display","none");
    }
  })

  currentMonth -= 1;

  $('#second_calendar .month-container').each(function(idx, el) {
    if (idx > currentMonth) {
      $(this).css("display","none");
    } else {
      $('#second_calendar .month-container').first().detach().appendTo("#first_calendar");
    }
  })

Don't forget to set startYear: new Date().getFullYear() on first calendar and startYear: new Date().getFullYear()+1 on second calendar.

@Paul-DS
Copy link
Owner

Paul-DS commented Apr 25, 2016

You want to display something like that ?

image

Yes currently this is not managed, especially because the calendar is displayed for a given (unique) year. The HMI is not intended for that (current year displayed at the top, etc..)

@krizajb
Copy link
Author

krizajb commented Apr 25, 2016

Yes, I needed that but as you can see I made a workaround, here is the solution (probably temporary address since it's not published yet, so I will update the url when so): http://www.shappa.si/koledar-new.html

@Paul-DS
Copy link
Owner

Paul-DS commented Apr 25, 2016

Ok super !

Given your example, I will add an option to remove the header. In this case it will not be present in the DOM (and not just hidden with CSS).

@Paul-DS
Copy link
Owner

Paul-DS commented May 19, 2016

I just added the option to display\hide the calendar header : displayHeader

@stevenbrown-85
Copy link

this solution is ok for just viewing the calendar but when trying to select a date range between December and January it doesn't work...

@jmrp81
Copy link

jmrp81 commented Jul 23, 2018

Thanks, It is a magnificent calendar @Paul-DS and the solution of the months has helped me @krizajb

@Paul-DS
Copy link
Owner

Paul-DS commented Apr 4, 2020

I know this thread is pretty old, but I'm working on this feature in the new version of the library: js-year-calendar
You can follow the development (and test the functionality) in the PR year-calendar#32

@Paul-DS
Copy link
Owner

Paul-DS commented Aug 24, 2021

The feature is available in js-year-calendar@v2.0.0. Check the options startDate and numberMonthsDisplayed in the documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants