Necr0manzer Posted January 3, 2006 Share Posted January 3, 2006 Ok, so here's my problem:I'm writing a script that converts today's date to the Discordian date!You might look up Wikipedia on Discordianism or something lke that or google for Principia Diskordia... :)Here's what i've written so far: var d=new Date() var day=d.getDate() var month=d.getMonth() + 1 var year=d.getFullYear() + 1166 var discday=new Array (5) discday[1]="Sweetmorn" discday[2]="Boomtime" discday[3]="Pungenday" discday[4]="Prickle-Prickle" discday[5]="Setting Orange" var discmonth=new Array (5) discmonth[0]="Chaos" discmonth[1]="Discord" discmonth[2]="Confusion" discmonth[3]="Bureaucracy" discmonth[4]="The Aftermath" if (day == 1) {document.write(discday[d.getDate()] + "," + " " + day + "st" + " " + discmonth[d.getMonth()] + " " + year) } else if (day == 2) { document.write(discday[d.getDate()] + "," + " " + day + "nd" + " " + discmonth[d.getMonth()] + " " + year)} else if (day == 3) { document.write(discday[d.getDate()] + "," + " " + day + "rd" + " " + discmonth[d.getMonth()] + " " + year) } else { document.write(discday[d.getDate()] + "," + " " + day + "th" + " " + discmonth[d.getMonth()] + " " + year) } As is it will only work for the first 5 days of the year and the endings after numbers only work til the 21st ...But whatever.... my question is: is there any tag or so that shows the day of the year and not day of the month of the year?So that the 9 of February -> Day 40 or so?Or is there any other way to convert this day/month/year thingy to days?Thanks!Oh...btw: www.necr0manzer.de/projekt.htm <- if you can read German then maybe reading this will help a bit... it's my homepage and it's all in german and i'm not going to translate it.... maybe use the google oracle? Link to comment Share on other sites More sharing options...
Necr0manzer Posted January 3, 2006 Author Share Posted January 3, 2006 ok....solved it by myself: var date = new Date();var y = date.getYear();var d = date.getDate();var m = date.getMonth();var SJahr = y % 4;var SHJahr = y % 100;var S4Jahr = y% 400;var STag = ((S4Jahr == "0") ? (1) : ((SHJahr == "0") ? (0) : ((SJahr == "0") ? (1) : (0))));var days = new Array(31,28,31,30,31,30,31,31,30,31,30,31);if(STag == 1) days[1] += 1; var i, x;for(i = 0, x = 0; i < m; i++) { x += days[i];}//Result:var DayOfYear = x += d; 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