Skip to content

Commit

Permalink
set format from constants by format name
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr committed Oct 2, 2024
1 parent df69bcc commit 6bc786e
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/User/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(Writer $writer, array $columns, Repository $config,
{
$this->writer = $writer;
$this->columns = $columns;
$this->format = $config->get('concrete.export.csv.datetime_format', 'ATOM');
$this->format = $this->getFormatByName($config->get('concrete.export.csv.datetime_format', 'ATOM'));
$this->dateHelper = $dateHelper;
$this->userInfoRepository = $userInfoRepository;
$this->groupRepository = $groupRepository;
Expand Down Expand Up @@ -228,4 +228,35 @@ protected function getRecords(): \Generator
$this->tick();
}
}

protected function getFormatByName(string $formatName = 'ATOM')
{
switch ($formatName) {
case 'COOKIE':
return DATE_COOKIE;
case 'RFC822':
return DATE_RFC822;
case 'RFC850':
return DATE_RFC850;
case 'RFC1036':
return DATE_RFC1036;
case 'RFC1123':
return DATE_RFC1123;
case 'RFC7231':
return DATE_RFC7231;
case 'RFC2822':
return DATE_RFC2822;
case 'RFC3339':
return DATE_RFC3339;
case 'RFC3339_EXTENDED':
return DATE_RFC3339_EXTENDED;
case 'RSS':
return DATE_RSS;
case 'W3C':
return DATE_W3C;
case 'ATOM':
default:
return DATE_ATOM;
}
}
}

0 comments on commit 6bc786e

Please sign in to comment.