0

I need to get the julian day of an arbitrary date in javascript (it should work for about +-50 years from now) for calculating the position of the sun. What is the easisest way in javascript to get that number, or is there already a method? Thank you

SOLVED: sdespont posted a good link

flawr
  • 10,814
  • 3
  • 41
  • 71
  • What did you try? What kind of research have you done? – sdespont Jan 05 '14 at 12:07
  • Possible duplicate: http://stackoverflow.com/questions/20666749/map-iso8601-date-time-string-to-julian-day-using-javascript – Jacob Jan 05 '14 at 12:08
  • One simple Google search : http://javascript.about.com/library/bljulday.htm – sdespont Jan 05 '14 at 12:08
  • 2
    possible duplicate of [Calculating Jday(Julian Day) in javascript](http://stackoverflow.com/questions/11759992/calculating-jdayjulian-day-in-javascript) – kumarharsh Jan 05 '14 at 12:10
  • Oh thanks sdespont, this is what I was looking for! I already read the other posts that Jacob and Kumar Harsh mentioned, but they do not answer my question. PS: @sdespont: I could not find this link in the first few pages of google resulsts for 'julian day javascript' and similar...=/ – flawr Jan 05 '14 at 12:49

1 Answers1

1

When I first wanted to know about finding sunrise and sunset times I was looking for answers on wikipedia but I'm no math wizard. I couldn't understand the formula, well maybe just a little. I knew that you needed to be able to iterate something from 0 to whatever the limit was. But what I had found outside of those was a web page to calculate the very formula that I had been seeing in Greek. Here is that web page. Looking at examples is not stealing in my mind. There are many other sites similar to this on the net. Some use Javascript others use Perl and PHP.

<img src="https://wikimedia.org/api/rest_v1/media/math/render/svg/45e26774ace10d6eb58299c5adcab50958a53d61" class="mwe-math-fallback-image-inline mw-math-element" aria-hidden="true" style="vertical-align: -2.505ex; width:70.501ex; height:6.176ex;" alt="&#10;J\!D\!N = &#10;\text{day} + &#10;\left\lfloor\frac{153m+2}{5}\right\rfloor +&#10;365y+&#10;\left\lfloor\frac{y}{4}\right\rfloor -&#10;\left\lfloor\frac{y}{100}\right\rfloor +&#10;\left\lfloor\frac{y}{400}\right\rfloor -&#10;32045&#10;" />
Douglas G. Allen
  • 2,203
  • 21
  • 20