Skip to content

Commit

Permalink
fix export dates are not localized (kimai#5368)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst authored Feb 20, 2025
1 parent 928b520 commit afaa845
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Entity/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class Invoice implements EntityWithMetaFields
#[Assert\NotNull]
#[Serializer\Expose]
#[Serializer\Groups(['Default'])]
#[Exporter\Expose(label: 'date', type: 'datetime')]
private ?\DateTime $createdAt = null;
#[ORM\Column(name: 'timezone', type: 'string', length: 64, nullable: false)]
private ?string $timezone = null;
Expand Down Expand Up @@ -176,6 +175,7 @@ public function getTotal(): float
return $this->total;
}

#[Exporter\Expose(name: 'createdAt', label: 'date', type: 'datetime')]
public function getCreatedAt(): ?\DateTime
{
if (!$this->localized) {
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class Project implements EntityWithMetaFields, EntityWithBudget, CreatedAt
#[Serializer\Groups(['Project_Entity'])]
#[Serializer\Type(name: "DateTime<'Y-m-d'>")]
#[Serializer\Accessor(getter: 'getOrderDate')]
#[Exporter\Expose(label: 'orderDate', type: 'datetime')]
private ?\DateTime $orderDate = null;
/**
* Project start date (times before this date cannot be recorded)
Expand All @@ -99,7 +98,6 @@ class Project implements EntityWithMetaFields, EntityWithBudget, CreatedAt
#[Serializer\Groups(['Project'])]
#[Serializer\Type(name: "DateTime<'Y-m-d'>")]
#[Serializer\Accessor(getter: 'getStart')]
#[Exporter\Expose(label: 'project_start', type: 'datetime')]
private ?\DateTime $start = null;
/**
* Project end time (times after this date cannot be recorded)
Expand All @@ -111,7 +109,6 @@ class Project implements EntityWithMetaFields, EntityWithBudget, CreatedAt
#[Serializer\Groups(['Project'])]
#[Serializer\Type(name: "DateTime<'Y-m-d'>")]
#[Serializer\Accessor(getter: 'getEnd')]
#[Exporter\Expose(label: 'project_end', type: 'datetime')]
private ?\DateTime $end = null;
#[ORM\Column(name: 'timezone', type: 'string', length: 64, nullable: true)]
private ?string $timezone = null;
Expand Down Expand Up @@ -291,6 +288,7 @@ protected function localizeDates(): void
$this->localized = true;
}

#[Exporter\Expose(name: 'orderDate', label: 'orderDate', type: 'date')]
public function getOrderDate(): ?\DateTime
{
$this->localizeDates();
Expand All @@ -309,6 +307,7 @@ public function setOrderDate(?\DateTime $orderDate): Project
return $this;
}

#[Exporter\Expose(name: 'start', label: 'project_start', type: 'date')]
public function getStart(): ?\DateTime
{
$this->localizeDates();
Expand All @@ -327,6 +326,7 @@ public function setStart(?\DateTime $start): Project
return $this;
}

#[Exporter\Expose(name: 'end', label: 'project_end', type: 'date')]
public function getEnd(): ?\DateTime
{
$this->localizeDates();
Expand Down
6 changes: 3 additions & 3 deletions tests/Entity/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public function testExportAnnotations(): void
['name', 'string'],
['customer', 'string'],
['orderNumber', 'string'],
['orderDate', 'datetime'],
['project_start', 'datetime'],
['project_end', 'datetime'],
['orderDate', 'date'],
['project_start', 'date'],
['project_end', 'date'],
['budget', 'float'],
['timeBudget', 'duration'],
['budgetType', 'string'],
Expand Down

0 comments on commit afaa845

Please sign in to comment.