Skip to content

Instantly share code, notes, and snippets.

@thedava
Created October 29, 2016 13:14
Show Gist options
  • Save thedava/0bdda30ed8b28c21f51c7a3541debe2e to your computer and use it in GitHub Desktop.
Save thedava/0bdda30ed8b28c21f51c7a3541debe2e to your computer and use it in GitHub Desktop.
A small PHP script for converting SOL (Mars days) into Earth days
<?php
/**
* Usage: php sol.php <amount of sols>
*
*/
date_default_timezone_set('UTC');
define('DAY_MARS', 3600 * 24 + 39 * 60 + 35); // 24h 39m 35s
define('DAY_EARTH', 3600 * 24);
define('SOL_QUOTA', DAY_MARS / DAY_EARTH);
$sol = max(1, (isset($argv, $argv[1])) ? (int)$argv[1] : 1);
echo 'SOL: ', $sol, PHP_EOL;
$days = $sol * SOL_QUOTA;
echo 'Days: ', round($days, 3) , PHP_EOL;
if ($days > 30) {
echo 'Month(s): ', round($days / 30, 2), PHP_EOL;
}
if ($days > 365) {
echo 'Year(s): ', round($days / 365, 2), PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment