Nedeku Posted November 23, 2012 Share Posted November 23, 2012 (edited) this is a personal side project of mine, i am trying to change the time constraints of the hours, minutes, seconds, as well as change the start of the year to whatever I want it to be. ie days are 35 hours long, hours are 92 minutes long, minutes are 16 seconds long, and seconds are 200 milliseconds long, and the start of the year is February 29th is the beginning of the year in corralation to today's date, and have all of this done in the 24 hour time format where when the program first loads it works i would like to have this done in JavaScript, can someone help me?? Edited November 23, 2012 by Nedeku Link to comment Share on other sites More sharing options...
Ingolme Posted November 24, 2012 Share Posted November 24, 2012 You would have to create your own new date object that took all that into account. Link to comment Share on other sites More sharing options...
Nedeku Posted November 25, 2012 Author Share Posted November 25, 2012 question is, how....could you show me an example?? Link to comment Share on other sites More sharing options...
Ingolme Posted November 25, 2012 Share Posted November 25, 2012 Do you know object-oriented programming? And if you do, do you know how to implement it in Javascript? Link to comment Share on other sites More sharing options...
Nedeku Posted November 25, 2012 Author Share Posted November 25, 2012 to both questions the answer is no Link to comment Share on other sites More sharing options...
Ingolme Posted November 25, 2012 Share Posted November 25, 2012 Oh, well. It also can be done in other ways but it's not going to be well organized. To start off, I would take a base unit (milliseconds) and then put the relation between that and every other time unit: // Second is 200 millisecondsvar second = 200;// Minutes are 16 seconds, or 16*200 millisecondsvar minute = 3200;// Hours are 92 minutes long or 92 * 3200 millisecondsvar hour = 294400;// Days are 35 hours long or 35 * 294400 millisecondsvar day = 10304000; Now I've encountered a problem with your system: There's no relation between our real timescale and your timescale. If it's November 25th today and 365 days pass in your fictional time system it won't be November 25th in the real world, it would be some other date. Have you designed a solution for this problem? Link to comment Share on other sites More sharing options...
Nedeku Posted November 26, 2012 Author Share Posted November 26, 2012 the only way i can see that the day correlation would be changed in that aspect would be to manually change each day to the desired specified day Link to comment Share on other sites More sharing options...
Ingolme Posted November 26, 2012 Share Posted November 26, 2012 While I can program a system that counts a relative amount of time between a start and end point, I can't program a system that associates your timescale to real world dates because the systems aren't compatible. I can program a fictional "calendar" if you can tell me which exact date you consider to be the zero point in time. For the real date we have a UNIX timestamp that has a zero point in January 1st, 1970. Link to comment Share on other sites More sharing options...
Nedeku Posted November 26, 2012 Author Share Posted November 26, 2012 well, those numbers that i mentioned before were example numbers.The time frames that i would be using isHours=1-20Minutes=1-40Seconds=1-80Milliseconds=1-1350the start date of the year is March 21, while the end date of the year is March 20, and while those days would coincide with today's date now since the time frame is maintained at 86,400 seconds, or 86,400,000 milliseconds, the only thing that would be truly changed is how many hours are in a day, how many minutes are in a hour, how many seconds are in a minute, and how many milliseconds are in a second Link to comment Share on other sites More sharing options...
justsomeguy Posted November 26, 2012 Share Posted November 26, 2012 It almost seems like the best way to do this would be to download a C compiler and check in the standard libraries for the time.h file, and go through that to look at their algorithms. The file should define constants for the various things you want to change. You could also check the sources files for Chromium or Firefox to see what's there. Link to comment Share on other sites More sharing options...
Nedeku Posted December 1, 2012 Author Share Posted December 1, 2012 well, i found a way to make the program work in javascript, however, it shows as to how many Hours, Minutes, and Seconds since 1-1-1970, i however, now all i need to do is break that down to show the current time, not the difference between now and 1-1-1970 Link to comment Share on other sites More sharing options...
Nedeku Posted December 1, 2012 Author Share Posted December 1, 2012 <p> </p><div><!DOCTYPE html></div><div><html></div><div><head></div><div><script></div><div>function startTime()</div><div>{</div><div>var s=Math.floor(new Date()/1350);</div><div>var m=Math.floor(s/80);</div><div>var h=Math.floor(m/40);</div><div>var today=Math.floor(h/20);</div><div> </div><div>// add a zero in front of numbers<10</div><div>m=checkTime(m);</div><div>s=checkTime(s);</div><div>document.getElementById('txt').innerHTML=h+":"+m+":"+s;</div><div>t=setTimeout(function(){startTime()},500);</div><div>}</div><div> </div><div>function checkTime(i)</div><div>{</div><div>if (i<10)</div><div> {</div><div> i="0" + i;</div><div> }</div><div>return i;</div><div>}</div><div></script></div><div></head></div><div> </div><div><body onload="startTime()"></div><div><div id="txt"></div></div><div></body></div><div></html></div><div> </div> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now