javascript - Scripts that get weeknumber, but changes to the next week every friday -
i have screen running , showing jobs of current week. use script calculate current week:
date.prototype.getweek = function() { var onejan = new date(this.getfullyear(),0,1); return math.ceil((((this - onejan) / 86400000) + onejan.getday()+1)/7); }
but show next week every friday. there easy way change current script changes on friday instead? maybe way change @ 10 (my timezone - cest)
all hints , pointers appreciated :)
if understood correctly can increment reutrned value if today friday
.
date.prototype.getweek = function() { var onejan = new date(this.getfullyear(),0,1); var weeknr = math.ceil((((this - onejan) / 86400000) + onejan.getday()+1)/7); return this.getday() == 5 ? weeknr + 1 : weeknr; }
keep in mind getday()
returns day of week (from 0 6) specified date. sunday 0, monday 1 , friday 5. can more details here.
Comments
Post a Comment