Prev month/year buttons issues #35

tagliala opened this Issue Apr 21, 2012 · 1 comment


None yet

2 participants



Unfortunately I have not a deep knowledge of your library or moment.js, so I think it's better to start a new issue rather than trying fixing myself and make a pull request

As you can see there:

there are some issues concerning next and previous buttons.

1) If you click on tne next month, you will not see the button to come back to April
2) If you go at September, the previous year button will appear.

I took a look at the library but since it is designed to work on almost all browser I don't know if touching something is good.

Anyway, the problem 1 is related to he following line 468 (I suppose):

if (diff > opts.months) {

maybe > is >=

other problems seems wrong calculations like the one above

Please let me know if you can fix them

Best regards


(sorry, the feedle doesn't work with firefox I don't know why)


Unfortunately I can't use git at the moment, so I can't make a pull request there is a suggested fix


Line 448:

if (diff <= 0) {

replace with:

if (diff < 0)

Line 458:

if (diff > opts.months) {

replace with:

if (diff >= opts.months) {

Line 470

if (month.add({Y:1}).diff(moment(), 'years') < 0) {

replace with

if (month.add({y:1}).diff(moment(), 'months') <= 0) {

Line 479

if (month.subtract({Y:1}).diff(moment(), 'years') > 0) {

replace with

if ((month.subtract({y:1}).diff(moment(), 'months') - (opts.months-1)) >= 0) {

Some considerations:

  • the uppercase Y when subtracting/adding seems not to work at all
  • year difference is rounded 'cause asFloat = true is not provided to diff, so I shifted to months difference
  • Months difference is better for today-future when calendar contains multiple months. opts.months is needed too, 'cause if you set up a calendar with months: 3 starting in April 2012, the previous year button will appear when April 2013 will be the first month on the left rather than the first one on the right (in the last case, you will be able to return back to february 2012)
@tagliala tagliala added a commit to tagliala/Kalendae that referenced this issue Apr 23, 2012
@tagliala tagliala Fixed ChiperSoft/Kalendae#35 5ab8f7f
@ChiperSoft ChiperSoft closed this Apr 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment