[Sat pass] Add date in the form

This commit is contained in:
Andreas Kristiansen
2024-12-07 17:38:20 +01:00
parent 9eab143b60
commit eab2c5200b
2 changed files with 17 additions and 6 deletions

View File

@@ -285,7 +285,7 @@ class Satellite extends CI_Controller {
$tle = new Predict_TLE($sat_tle->satellite, $temp[0], $temp[1]); // Instantiate it
$sat = new Predict_Sat($tle); // Load up the satellite data
$now = Predict_Time::get_current_daynum(); // get the current time as Julian Date (daynum)
$now = $this->get_daynum_from_date($this->security->xss_clean($this->input->post('date'))); // get the current time as Julian Date (daynum)
// You can modify some preferences in Predict(), the defaults are below
//
@@ -316,4 +316,17 @@ class Satellite extends CI_Controller {
$data['format'] = $format;
$this->load->view('satellite/passtable', $data);
}
public static function get_daynum_from_date($date) {
// Convert a Y-m-d date to a day number
// Convert date to Unix timestamp
$timestamp = strtotime($date);
if ($timestamp === false) {
throw new Exception("Invalid date format. Expected Y-m-d.");
}
// Calculate the day number
return Predict_Time::unix2daynum($timestamp, 0);
}
}

View File

@@ -469,12 +469,10 @@
<option ">Etc/GMT+12</option>
</select>
</div>
<!-- <div class="mb-3 w-auto">
<div class="mb-3 w-auto">
<label class="my-1 me-sm-2 w-auto" for="date"><?= __("Date"); ?></label>
<select class="my-1 me-sm-2 w-auto form-select" id="date" name="start">
<option selected value="0"><?= __("Today"); ?></option>
</select>
</div> -->
<input name="date" id="date" type="date" class="form-control form-control-sm w-auto" value="<?php echo date('Y-m-d'); ?>" >
</div>
<div class="mb-3 w-auto">
<label class="my-1 me-sm-2 w-auto" for="mintime"><?= __("Min. time"); ?></label>
<select class="my-1 me-sm-2 w-auto form-select" id="mintime" name="mintime">