Fix datetime parser

This commit is contained in:
Nabeel Shahzad
2018-08-26 12:25:51 -05:00
parent 046dac5db5
commit 0f3424f41e
3 changed files with 18 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
# phpvms <sup>7</sup> # phpvms <sup>7</sup>
[![Build Status](https://travis-ci.org/nabeelio/phpvms.svg)](https://travis-ci.org/nabeelio/phpvms) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d668bebb0a3c46bda381af16ce3d9450)](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nabeelio/phpvms&amp;utm_campaign=Badge_Grade) [![Total Downloads](https://poser.pugx.org/nabeel/phpvms/downloads)](https://packagist.org/packages/nabeel/phpvms) [![Latest Stable Version](https://poser.pugx.org/nabeel/phpvms/v/stable)](https://packagist.org/packages/nabeel/phpvms) [![Latest Unstable Version](https://poser.pugx.org/nabeel/phpvms/v/unstable)](https://packagist.org/packages/nabeel/phpvms) [![License](https://poser.pugx.org/nabeel/phpvms/license)](https://packagist.org/packages/nabeel/phpvms) [![Build Status](https://travis-ci.org/nabeelio/phpvms.svg)](https://travis-ci.org/nabeelio/phpvms) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/d668bebb0a3c46bda381af16ce3d9450)](https://www.codacy.com/app/nabeelio/phpvms?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nabeelio/phpvms&amp;utm_campaign=Badge_Grade) [![Latest Stable Version](https://poser.pugx.org/nabeel/phpvms/v/stable)](https://packagist.org/packages/nabeel/phpvms) ![StyleCI](https://github.styleci.io/repos/93688482/shield?branch=dev) [![License](https://poser.pugx.org/nabeel/phpvms/license)](https://packagist.org/packages/nabeel/phpvms)
The next phpvms version built on the laravel framework. work in progress. If you're looking for The next phpvms version built on the laravel framework. work in progress. If you're looking for
the old, phpVMS classic, it's [available here](https://github.com/nabeelio/phpvms_v2). the old, phpVMS classic, it's [available here](https://github.com/nabeelio/phpvms_v2).

View File

@@ -147,11 +147,19 @@ class AcarsController extends Controller
$position['type'] = AcarsType::FLIGHT_PATH; $position['type'] = AcarsType::FLIGHT_PATH;
if (array_key_exists('sim_time', $position)) { if (array_key_exists('sim_time', $position)) {
$position['sim_time'] = Carbon::createFromTimeString($position['sim_time']); if ($position['sim_time'] instanceof \DateTime) {
$position['sim_time'] = Carbon::instance($position['sim_time']);
} else {
$position['sim_time'] = Carbon::createFromTimeString($position['sim_time']);
}
} }
if (array_key_exists('created_at', $position)) { if (array_key_exists('created_at', $position)) {
$position['created_at'] = Carbon::createFromTimeString($position['created_at']); if ($position['created_at'] instanceof \DateTime) {
$position['created_at'] = Carbon::instance($position['created_at']);
} else {
$position['created_at'] = Carbon::createFromTimeString($position['created_at']);
}
} }
$update = Acars::create($position); $update = Acars::create($position);

View File

@@ -78,6 +78,12 @@ class MetarTest extends TestCase
$this->assertEquals('AO2 PK WND 27045/2128 PRESRR SLP018 T01221044', $parsed['remarks']); $this->assertEquals('AO2 PK WND 27045/2128 PRESRR SLP018 T01221044', $parsed['remarks']);
} }
public function testMetar2()
{
$metar = 'EGLL 261250Z AUTO 17014KT 8000 -RA BKN010/// '
.'BKN016/// OVC040/// //////TCU 13/12 Q1008 TEMPO 4000 RA';
}
public function testMetarTrends() public function testMetarTrends()
{ {
$metar = $metar =
@@ -116,4 +122,5 @@ class MetarTest extends TestCase
$this->assertEquals('VFR', $metar['category']); $this->assertEquals('VFR', $metar['category']);
$this->assertNotNull($metar); $this->assertNotNull($metar);
} }
} }