lib/lune.js
function phase_hunt (sdate) {
  if (!sdate) {
    sdate = new Date()
  }

  let adate = new Date(sdate.getTime() - (45 * 86400000)) // 45 days prior
  let k1 = Math.floor(12.3685 * (adate.getFullYear() + (1.0 / 12.0) * adate.getMonth() - 1900))
  let nt1 = meanphase(adate.getTime(), k1)

  sdate = julian.fromDate(sdate)
  adate = nt1 + SYNODIC_MONTH
  let k2 = k1 + 1
  let nt2 = meanphase(adate, k2)
  while (nt1 > sdate || sdate >= nt2) {
    adate += SYNODIC_MONTH
    k1++
    k2++
    nt1 = nt2
    nt2 = meanphase(adate, k2)
  }

  return {
    new_date: truephase(k1, NEW),
    q1_date: truephase(k1, FIRST),
    full_date: truephase(k1, FULL),
    q3_date: truephase(k1, LAST),
    nextnew_date: truephase(k2, NEW)
  }
}
function phase_hunt (sdate) {
  if (!sdate) {
    sdate = new Date()
  }

  let adate = new Date(sdate.getTime() - (45 * 86400000)) // 45 days prior
  let k1 = Math.floor(12.3685 * (adate.getFullYear() + (1.0 / 12.0) * adate.getMonth() - 1900))
  let nt1 = meanphase(adate.getTime(), k1)

  sdate = julian.fromDate(sdate)
  adate = nt1 + SYNODIC_MONTH
  let k2 = k1 + 1
  let nt2 = meanphase(adate, k2)
  while (nt1 > sdate || sdate >= nt2) {
    adate += SYNODIC_MONTH
    k1++
    k2++
    nt1 = nt2
    nt2 = meanphase(adate, k2)
  }

  return {
    new_date: truephase(k1, NEW),
    q1_date: truephase(k1, FIRST),
    full_date: truephase(k1, FULL),
    q3_date: truephase(k1, LAST),
    nextnew_date: truephase(k2, NEW)
  }
}
function phase_hunt ( sdate ) { if ( ! sdate ) { sdate = new Date ( ) } let adate = new Date ( sdate . getTime ( ) - ( 45 * 86400000 ) ) // 45 days prior let k1 = Math . floor ( 12.3685 * ( adate . getFullYear ( ) + ( 1.0 / 12.0 ) * adate . getMonth ( ) - 1900 ) ) let nt1 = meanphase ( adate . getTime ( ) , k1 ) sdate = julian . fromDate ( sdate ) adate = nt1 + SYNODIC_MONTH let k2 = k1 + 1 let nt2 = meanphase ( adate , k2 ) while ( nt1 > sdate || sdate >= nt2 ) { adate += SYNODIC_MONTH k1 ++ k2 ++ nt1 = nt2 nt2 = meanphase ( adate , k2 ) } return { new_date : truephase ( k1 , NEW ) , q1_date : truephase ( k1 , FIRST ) , full_date : truephase ( k1 , FULL ) , q3_date : truephase ( k1 , LAST ) , nextnew_date : truephase ( k2 , NEW ) } }
Find time of phases of the moon which surround the current date.
Five phases are found, starting and ending with the new moons
which bound the current lunation.
@param  {Date} sdate Date to start hunting from (defaults to current date)
@return {Object}     Object containing recent past and future phases
Find time of phases of the moon which surround the current date . Five phases are found starting and ending with the new moons which bound the current lunation .