-
August 27th, 2011, 08:38 PM #1Junior Member
- Join Date
- Aug 2011
- Posts
- 2
how to edit this JS code -DAY OF CYCLE
I have this code on our high school website that displays the day of the cycle, for example "Today is day 3". On the weekends it will say "Monday is day 4". We are changing from an 8 day cycle to a 4 day cycle. What do I need to edit on the code below to switch it from an 8 day to a 4 day cycle?I cannot get in touch with the author as it was a former student. Thanks!
function cycleday(last, day){
day = day-1;
//Set the two dates
var lday = last;
today=new Date();
//Get 1 day in milliseconds
var one_day=1000*60*60*24;
//how far from the end of the week that day was
offset = lday.getDay();
//get how many weekends since then
ends = Math.ceil((today.getTime()-lday.getTime())/(one_day));
ends += offset;
ends = Math.floor(ends/7);
//Calculate difference btw the two dates, and convert to days
d = Math.ceil((today.getTime()-lday.getTime())/(one_day));
//subtract the weekends
d = d + day - 1 - ends*2;
//how many days of the cycle
d = d%4;
if (today.getDay() == 0 || today.getDay() == 6){
d += 2;
return "Monday is Day " + d;}
else{
d += 1;
return "Today is Day " + d;}
}
function cycle(){
//update if the counter is off
var lastday = new Date(2010, 4-1, 16); //yyyy, mm-1, dd
var thatday = 2; //the day of the cycle it was
document.write("<span class='cycle'>");
document.write(cycleday(lastday, thatday));
document.write("</div><br><br>");
}
-
August 27th, 2011, 10:08 PM #2Junior Member
- Join Date
- Aug 2011
- Posts
- 2
to clarify further...
If "Monday is day 4", the next day Tuesday will be day 1, Wednesday day 2, Thursday is day 3 and Friday would then be day 4. Then the following Monday would be day 1.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Constant on/off cycle
By DonnaRonna in forum Technical SupportReplies: 1Last Post: July 19th, 2011, 11:50 AM -
Can someone help with a code edit ?
By noxx in forum Webmastering and ProgrammingReplies: 0Last Post: May 17th, 2011, 01:48 PM -
The Galactic Equinox Cycle
By SiliconJon in forum IMO CommunityReplies: 3Last Post: February 6th, 2007, 11:00 AM -
Windows Life Cycle
By Ben Humphreys in forum General Tech DiscussionReplies: 2Last Post: April 4th, 2006, 12:09 PM -
Burn: cycle
By thePh@r@oh in forum General Gaming DiscussionReplies: 5Last Post: November 24th, 2003, 03:30 PM



LinkBack URL
About LinkBacks



Reply With Quote

Delete a hard disk partition
How do i delete a partition that i...