Enjoy an ad free experience by logging in. Not a member yet? Register.

Results 16 to 18 of 18
Thread: I need this programmed...

11172012, 04:50 AM #16
 Join Date
 Nov 2012
 Posts
 9
 Thanks
 1
 Thanked 0 Times in 0 Posts
I see. No problem.
Perhaps you can help fix with this other one that i almost have working.
7 days = 1 week
7 weeks = 1 month
7 months = 1 year (343 days)
the 8th year is 7 months of 21 days
the 9th year is 9 days
After the 9th year it gets cycled into a new cycle where the years start to recount
This cycle system lines up so that at the end of the 28th year in the julian system ends on the same day as the 4th cycle of this system with 10227 days.
the current problem i'm having is that 2401 days should be the last day of the 7th year... It is returning a year 8 day 0
edit  I found the same problem in my julien calender code... The last day of every year is zero'd out.
this is what i have... yeah i know my naming conventionbs are sloppy v.v
Code:function DrCal(days) { drCycle = 2557 drYeara = 343 drYearb = 147 //drYearc = 9 Cycle = Math.floor(days/drCycle) DaysNotOfCycle = Cycle * drCycle DaysOfCycle = days  DaysNotOfCycle var drMonth=new Array("m1","m2","m3","m4","m5","m6","m7") var drMonthEnd=new Array("49","98","147","196","245","294","343") var drMonthb=new Array("m1","m2","m3","m4","m5","m6","m7") var drMonthbEnd=new Array("21","42","63","84","105","126","147") if(DaysOfCycle <= 2401) { drYear = Math.floor(DaysOfCycle / drYeara) DaysNotOfYear = drYear*drYeara // causing problem drYear++ DaysOfYear = DaysOfCycle  DaysNotOfYear //causing problem theMonth = 0 for (m = 0; m < 7; m++) { if(DaysOfYear <= drMonthEnd[m]) { theMonth = m; break;} } Month = drMonth[theMonth] if(theMonth > 0) { drDate = DaysOfYear  drMonthEnd[theMonth1] }else{ drDate = DaysOfYear } } else if ((DaysOfCycle > 2401) && (DaysOfCycle <= 2548)) { drYear = 8 DaysOfYear = DaysOfCycle  (drYeara*7) theMonth = 0 for (m = 0; m < 7; m++) { if(DaysOfYear <= drMonthbEnd[m]) { theMonth = m; break;} } Month = drMonthb[theMonth] if(theMonth > 0) { drDate = DaysOfYear  drMonthbEnd[theMonth1] }else{ drDate = DaysOfYear } }else{ drYear = 9 drDate = DaysOfCycle  (drYeara+drYearb) Month = 1 } Cycle++ document.write("<br />Dr Cycle: " +Cycle+ " Year:" +drYear+ " Month:" +Month+ " " +drDate) }
I have figured a solution to my problem. I switched to your code, Pedant, and add 3 changes... 1 nonimportant, 1 I moved the function to a subfunction so i can call another date system, and I corrected one minor little problem
Code:var yrs = (4 * quads) +1;
Everything else as far as I have tested works great and I am using the way you coded this one to try to code the other one i mentioned...
here's the code so far
Code:var nDays = Number( document.getElementById("days").value ); var Cycle = Math.floor(nDays / 2557); if(nDays%2557 != 0) { nDays = Cycle*2557; Cycle++; } /* var mnames = ["Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec" ]; var mDays = [ 31,28,31,30,31,30,31,31,30,31,30,31 ]; // handle leap year: mDays[1] = ( yrs % 4 == 0 ) ? 29 : 28; var theMonth = 1; for ( var m = 0; m < 12; ++m ) { if ( nDays <= mDays[m] ) { theMonth = m; break; // out of for loop } nDays = mDays[m]; } var monthName = mnames[theMonth]; */ document.getElementById("jDate").innerHTML = "Cycle: " +Cycle+ " Days: " +nDays;
I do however have a question... when I merge these two together, will the var names cause a problem. I forget how var localization in JS works.Last edited by Durakken; 11172012 at 10:26 AM.

11172012, 11:44 PM #17
 Join Date
 Nov 2012
 Posts
 9
 Thanks
 1
 Thanked 0 Times in 0 Posts
Grrr... so I got the next one all programmed out... and now I'm stuck yet again...
Whenever a multiple of 2557 is entered the date returned is wrong and this seems to push the date off a little.
Here's the code. I'm pretty sure it has something to do with the fix I tried with nDays%2557
edit: ^.^ I figured out what the problem was sort of, (and edited it into the code) but I also forgot something... which kinda throws a wrench into this whole thing like the leap year thing did... This system is supposed to have a reverse leap year which is why 10227 is supposed to align with the Julian Calender. The reverse leap is supposed to be that last day off the 4th Cycle. Is there any way to fudge this so that that happens and is still accurate or is do I have to refigure this out?
edit2: never mind...fixed ^.^ I just used day subtraction after i realized that if i subtract 10227 from 10228 it'll restart with 1 so i just needed a way to keep track of the cycles after that. yar
Code:<html> <body> <form id="theForm" onsubmit="return false;"> Number of days: <input id="days" name="days" onchange="getDate();" /> <br/> <input type="button" value="Calculate" onclick="getDate();" /> </form> <hr/> Dr date: <span id="jDate"></span> <script type="text/javascript"> function getDate() { getJulianDate() } function getJulianDate( ) { var nDays = Number( document.getElementById("days").value ); var Cycle = Math.floor(nDays / 2557); if(nDays%2557 != 0) { nDays = Cycle*2557; Cycle++; } else { nDays = 2557; } var years = [343,343,343,343,343,343,343,147,9]; theYear = 0; for ( var y = 0; y < 9; ++y) { if ( nDays <= years[y] ) { theYear = y +1; break; } nDays = years[y] } var mnames = ["Darusitar","Bendratar","Enzer","Mizutar","Genutar","Krinzitar", "Niemetar"]; var mDays = [ 49,21 ]; var s = 0; if (theYear >= 8) { s = 1; } var theMonth = 1; for ( var m = 0; m < 7; ++m ) { if ( nDays <= mDays[s] ) { theMonth = m; break; // out of for loop } nDays = mDays[s]; } if ( theYear == 9) { var monthName = "Morgetar"; } else { var monthName = mnames[theMonth]; } document.getElementById("jDate").innerHTML = monthName+ " " +nDays+ ", " +theYear+"."+Cycle+ "T"; } </script> </body> </html>
Last edited by Durakken; 11182012 at 02:31 AM.

11192012, 09:32 PM #18
I haven't go time to look further right now, but will be back later.
In the meantime, it *SOUNDS* like the same problem I has with zerobased vs. 1base years.
I *think* your answer will be to pull the same trick I did:
Code:var nines = Math.floor( ( nDays  1 ) / 2557 ); nDays = nines * 2557; var yrs = 9 * nines;
I know it feels clumsy, but it solves the zerobased vs. onebased problem.Be yourself. No one else is as qualified.