Skip to content

Commit 128d8fe

Browse files
authored
Merge pull request #99 from mogic-le/geo-float
Fix GEO coordinates on locale with comma as decimal separator
2 parents 789422f + bbd3551 commit 128d8fe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Properties/CoordinatesProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(string $name, float $lat, float $lng)
2222

2323
public function getValue(): string
2424
{
25-
return "{$this->lat};{$this->lng}";
25+
return json_encode($this->lat) . ';' . json_encode($this->lng);
2626
}
2727

2828
public function getOriginalValue(): array

tests/Properties/CoordinatesPropertyTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Spatie\IcalendarGenerator\Tests\Properties;
4+
35
use Spatie\IcalendarGenerator\Properties\CoordinatesProperty;
46
use Spatie\IcalendarGenerator\Tests\PropertyExpectation;
57

@@ -11,3 +13,13 @@
1113
->expectOutput('10.5;20.5')
1214
->expectValue(['lat' => 10.5, 'lng' => 20.5]);
1315
});
16+
17+
test('it_has_dot_as_decimal_point', function () {
18+
setlocale(LC_ALL, 'de_DE.UTF-8');
19+
$propertyType = new CoordinatesProperty('GEO', 10.5, 20.5);
20+
21+
PropertyExpectation::create($propertyType)
22+
->expectName('GEO')
23+
->expectOutput('10.5;20.5')
24+
->expectValue(['lat' => 10.5, 'lng' => 20.5]);
25+
});

0 commit comments

Comments
 (0)