mirror of
https://framagit.org/tykayn/date-poll-api
synced 2023-08-25 08:23:11 +02:00
format date string for choices in poll of date kind
This commit is contained in:
parent
8c2ad610a5
commit
ecdbf3fb33
@ -67,13 +67,19 @@ class Choice {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function display() {
|
||||
return [
|
||||
public function display( $kind = 'text' ) {
|
||||
$fields = [
|
||||
'id' => $this->getId(),
|
||||
'created_at' => $this->getCreatedAtAsString(),
|
||||
'name' => $this->getName(),
|
||||
'url' => $this->getUrl(),
|
||||
];
|
||||
if ( $kind === 'date' ) {
|
||||
$date = new DateTime( $this->getName() );
|
||||
$fields[ 'name' ] = $date->format( 'c' );
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function getId(): ?int {
|
||||
|
@ -290,7 +290,7 @@ class Poll {
|
||||
|
||||
// first, prefill all choices
|
||||
foreach ( $this->getChoices() as $choice ) {
|
||||
$computedArray[ $choice->getId() ] = array_merge($scoreInfos, $choice->display());
|
||||
$computedArray[ $choice->getId() ] = array_merge($scoreInfos, $choice->display($this->getKind()));
|
||||
}
|
||||
// then, compute stack of votes scores on each choice
|
||||
foreach ( $this->getStacksOfVotes() as $stack_of_vote ) {
|
||||
|
Loading…
Reference in New Issue
Block a user