You are here

function date_calc_date_season in Date 6.2

Same name and namespace in other branches
  1. 5.2 date_php4/date_php4_calc.inc \date_calc_date_season()
  2. 6 date_php4/date_php4_calc.inc \date_calc_date_season()

Determines julian date of the given season

Adapted from previous work in Java by James Mark Hamilton.

@author James Mark Hamilton <mhamilton@qwest.net> @author Robert Butler <rob@maxwellcreek.org>

Parameters

string $season: The season to get the date for: VERNALEQUINOX, SUMMERSOLSTICE, AUTUMNALEQUINOX, or WINTERSOLSTICE.

string $year: The year in four digit format. Must be between -1000BC and 3000AD.

Return value

float The julian date the season starts on.

File

date_php4/date_php4_calc.inc, line 352

Code

function date_calc_date_season($season, $year = 0) {
  if ($year == '') {
    $year = date_calc_get_year();
  }
  if ($year >= -1000 && $year <= 1000) {
    $y = $year / 1000.0;
    switch ($season) {
      case 'VERNALEQUINOX':
        $date_calc_julian_date = (((-0.00071 * $y - 0.00111) * $y + 0.06134) * $y + 365242.1374) * $y + 1721139.29189;
        break;
      case 'SUMMERSOLSTICE':
        $date_calc_julian_date = (((0.00025 * $y + 0.00907) * $y - 0.05323) * $y + 365241.72562) * $y + 1721233.25401;
        break;
      case 'AUTUMNALEQUINOX':
        $date_calc_julian_date = (((0.00074 * $y - 0.00297) * $y - 0.11677) * $y + 365242.49558) * $y + 1721325.70455;
        break;
      case 'WINTERSOLSTICE':
      default:
        $date_calc_julian_date = (((-6.0E-5 * $y - 0.00933) * $y - 0.00769) * $y + 365242.88257) * $y + 1721414.39987;
    }
  }
  elseif ($year > 1000 && $year <= 3000) {
    $y = ($year - 2000) / 1000;
    switch ($season) {
      case 'VERNALEQUINOX':
        $date_calc_julian_date = (((-0.00057 * $y - 0.00411) * $y + 0.05169) * $y + 365242.37404) * $y + 2451623.80984;
        break;
      case 'SUMMERSOLSTICE':
        $date_calc_julian_date = (((-0.0003 * $y + 0.008880000000000001) * $y + 0.00325) * $y + 365241.62603) * $y + 2451716.56767;
        break;
      case 'AUTUMNALEQUINOX':
        $date_calc_julian_date = (((0.00078 * $y + 0.00337) * $y - 0.11575) * $y + 365242.01767) * $y + 2451810.21715;
        break;
      case 'WINTERSOLSTICE':
      default:
        $date_calc_julian_date = (((0.00032 * $y - 0.008229999999999999) * $y - 0.06223) * $y + 365242.74049) * $y + 2451900.05952;
    }
  }
  return $date_calc_julian_date;
}