| 1 | <?php |
||
| 9 | class DocMarsTest extends TestCase |
||
| 10 | { |
||
| 11 | protected $factory; |
||
| 12 | protected $mars; |
||
| 13 | |||
| 14 | public function setUp() |
||
| 15 | { |
||
| 16 | $this->factory = new ConfigurableFactory(); |
||
| 17 | $this->mars = $this->factory->build([ |
||
| 18 | 'era_start' => -3029702400, |
||
| 19 | 'era_start_year' => 1, |
||
| 20 | 'day_length' => 88775.244, |
||
| 21 | 'year_length' => 668.5991, |
||
| 22 | 'leap' => 'float', |
||
| 23 | 'month' => 'equal_length', |
||
| 24 | 'month_length' => 30, |
||
| 25 | 'week' => 'iso', |
||
| 26 | 'era_start_day_index' => 1, |
||
| 27 | 'week' => 'simple', |
||
| 28 | 'week_length' => 10, |
||
| 29 | ]); |
||
| 30 | } |
||
| 31 | |||
| 32 | public function testMarsTime() |
||
| 33 | { |
||
| 34 | $this->assertEquals( |
||
| 35 | $this->mars->format( |
||
| 36 | new DateTime('1873-12-30 00:00:00'), |
||
| 37 | "Y-m-d H:i:s" |
||
| 38 | ), |
||
| 39 | '0001-01-01 23:21:28' |
||
| 40 | ); |
||
| 41 | |||
| 42 | /** |
||
| 43 | * According to http://jtauber.github.io/mars-clock/, the MSD of this date |
||
| 44 | * is 51232 sols after 1873-12-29 00:00:00 UTC, which is our era start. |
||
| 45 | * That means the internal eraDayIndex should be 51232 aswell, year should be |
||
| 46 | * ceil(51232/668.5921) = 77, and day index should be (51232 mod 668.5921) = 419 |
||
| 47 | */ |
||
| 48 | $this->assertEquals( |
||
| 49 | $this->mars->format( |
||
| 50 | new DateTime('2018-02-13 00:00:00 UTC'), |
||
| 51 | "Y z" |
||
| 52 | ), |
||
| 53 | '0077 419' |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |