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

week with id "0" #32

Open
julbuel opened this issue Apr 11, 2013 · 2 comments
Open

week with id "0" #32

julbuel opened this issue Apr 11, 2013 · 2 comments

Comments

@julbuel
Copy link

julbuel commented Apr 11, 2013

there seems to be a problem with the week id

for the first week of 2014, it shows 0

image

and if you have a value that start Jan 01 2013 to Dec 31 2013
it makes something weird, the item take the size of the label inside :

image

@julbuel
Copy link
Author

julbuel commented Apr 11, 2013

to correct this i've done the following
i changed the getWeekofYear function
Date.prototype.getWeekOfYear = function () {
var ys = new Date(this.getFullYear(), 0, 1);
var sd = new Date(this.getFullYear(), this.getMonth(), this.getDate());
/if (ys.getDay() > 3) {
ys = new Date(sd.getFullYear(), 0, (7 - ys.getDay()));
}
/
sd.setDate(sd.getDate() + 4 - (sd.getDay() || 7));
var daysCount = sd.getDayOfYear() - ys.getDayOfYear();
//return (Math.ceil(daysCount / 7));
return Math.ceil((((sd - ys) / 86400000) + 1) / 7)
};

and i changed the getdayforweek function

Date.prototype.getDayForWeek = function () {
var df = new Date(this.valueOf());
df.setDate(df.getDate() - df.getDay());
var dt = new Date(this.valueOf());
/dt.setDate(dt.getDate() + (6 - dt.getDay()));
if ((df.getMonth() === dt.getMonth()) || (df.getMonth() !== dt.getMonth() && dt.getDate() >= 4)) {
return new Date(dt.setDate(dt.getDate() - 3));
} else {
return new Date(df.setDate(df.getDate() + 3));
}
/
return new Date(dt.setDate(dt.getDate() + 4 - (dt.getDay() || 7)));
};

@dmromanov
Copy link
Contributor

@julbuel That works for 2014, but 2015 starts again with week "0".

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

2 participants