Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/Backend/Core/Engine/DataGridFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ public static function getDate(int $timestamp): string
return '';
}

// get user setting for long dates
$format = Authentication::getUser()->getSetting('date_format');
$format = 'j F Y';

// format the date according the user his settings
return SpoonDate::getDate($format, $timestamp, BackendLanguage::getInterfaceLanguage());
}

Expand All @@ -91,10 +89,8 @@ public static function getLongDate(int $timestamp): string
return '';
}

// get user setting for long dates
$format = Authentication::getUser()->getSetting('datetime_format');
$format = 'j F Y H:i';

// format the date according the user his settings
return SpoonDate::getDate($format, $timestamp, BackendLanguage::getInterfaceLanguage());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventueel ook al SpoonDate weghalen. Als je dat in apart ticket gaat doen, mag je dit negeren.

}

Expand All @@ -112,10 +108,8 @@ public static function getTime(int $timestamp): string
return '';
}

// get user setting for long dates
$format = Authentication::getUser()->getSetting('time_format');
$format = 'H:i';

// format the date according the user his settings
return SpoonDate::getDate($format, $timestamp, BackendLanguage::getInterfaceLanguage());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventueel ook al SpoonDate weghalen. Als je dat in apart ticket gaat doen, mag je dit negeren.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ja ik heb een aparte taak aangemaakt daarvoor

}

Expand All @@ -129,7 +123,7 @@ public static function getTime(int $timestamp): string
public static function getTimeAgo(int $timestamp): string
{
// get user setting for long dates
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment weghalen

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$format = Authentication::getUser()->getSetting('datetime_format');
$format = 'j F Y H:i';

// get the time ago as a string
$timeAgo = SpoonDate::getTimeAgo($timestamp, BackendLanguage::getInterfaceLanguage(), $format);
Expand Down
61 changes: 0 additions & 61 deletions src/Backend/Core/Engine/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,50 +265,6 @@ public static function generateRandomString(
return $string;
}

/**
* Fetch the list of long date formats including examples of these formats.
*
* @return array
*/
public static function getDateFormatsLong(): array
{
$possibleFormats = [];

// loop available formats
foreach ((array) self::get('fork.settings')->get('Core', 'date_formats_long') as $format) {
// get date based on given format
$possibleFormats[$format] = \SpoonDate::getDate(
$format,
null,
Authentication::getUser()->getSetting('interface_language')
);
}

return $possibleFormats;
}

/**
* Fetch the list of short date formats including examples of these formats.
*
* @return array
*/
public static function getDateFormatsShort(): array
{
$possibleFormats = [];

// loop available formats
foreach ((array) self::get('fork.settings')->get('Core', 'date_formats_short') as $format) {
// get date based on given format
$possibleFormats[$format] = \SpoonDate::getDate(
$format,
null,
Authentication::getUser()->getSetting('interface_language')
);
}

return $possibleFormats;
}

public static function getExtras(array $ids): array
{
// get database
Expand Down Expand Up @@ -453,23 +409,6 @@ public static function getNumberFormats(): array
return (array) self::get('fork.settings')->get('Core', 'number_formats');
}

/**
* Fetch the list of time formats including examples of these formats.
*
* @return array
*/
public static function getTimeFormats(): array
{
$possibleFormats = [];
$interfaceLanguage = Authentication::getUser()->getSetting('interface_language');

foreach (self::get('fork.settings')->get('Core', 'time_formats') as $format) {
$possibleFormats[$format] = \SpoonDate::getDate($format, null, $interfaceLanguage);
}

return $possibleFormats;
}

/**
* Get the token which will protect us
*
Expand Down
48 changes: 32 additions & 16 deletions src/Backend/Core/Engine/TemplateModifiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Backend\Core\Engine\Model as BackendModel;
use Common\Core\Twig\Extensions\BaseTwigModifiers;
use Backend\Core\Language\Language as BackendLanguage;
use SpoonDate;
use IntlDateFormatter;
use function Symfony\Component\String\s;

/**
Expand All @@ -23,15 +23,20 @@ class TemplateModifiers extends BaseTwigModifiers
*/
public static function formatDate($var): string
{
// get setting
$format = Authentication::getUser()->getSetting('date_format');
Comment thread
jonasdekeukelaere marked this conversation as resolved.

if ($var instanceof \DateTime) {
$var = $var->getTimestamp();
}

// format the date
return SpoonDate::getDate($format, (int) $var, BackendLanguage::getInterfaceLanguage());
$date = new IntlDateFormatter(
BackendLanguage::getInterfaceLanguage(),
IntlDateFormatter::SHORT,
IntlDateFormatter::NONE,
null,
null,
'dd MMMM yyyy'
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
)->format((int) $var);

return $date;
}

/**
Expand All @@ -44,15 +49,21 @@ public static function formatDate($var): string
*/
public static function formatDateTime($var): string
{
// get setting
$format = Authentication::getUser()->getSetting('datetime_format');
Comment thread
jonasdekeukelaere marked this conversation as resolved.

if ($var instanceof \DateTime) {
$var = $var->getTimestamp();
}

// format the date
return SpoonDate::getDate($format, (int) $var, BackendLanguage::getInterfaceLanguage());
$date = new IntlDateFormatter(
BackendLanguage::getInterfaceLanguage(),
IntlDateFormatter::SHORT,
IntlDateFormatter::SHORT,
null,
null,
'dd MMMM yyyy HH:mm'
)->format((int) $var);

return $date;
}

/**
Expand Down Expand Up @@ -114,23 +125,28 @@ public static function formatNumber(float $number, ?int $decimals = null): strin

/**
* Format a UNIX-timestamp as a date
* syntax: {{ $var|formatdate }}
* syntax: {{ $var|formattime }}
*
* @param int|\DateTime $var The UNIX-timestamp to format.
*
* @return string
*/
public static function formatTime($var): string
{
// get setting
$format = Authentication::getUser()->getSetting('time_format');
Comment thread
jonasdekeukelaere marked this conversation as resolved.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem hier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is er dus uit


if ($var instanceof \DateTime) {
$var = $var->getTimestamp();
}

// format the date
return SpoonDate::getDate($format, (int) $var, BackendLanguage::getInterfaceLanguage());
$date = new IntlDateFormatter(
BackendLanguage::getInterfaceLanguage(),
IntlDateFormatter::NONE,
IntlDateFormatter::SHORT,
null,
null,
'HH:mm'
)->format((int) $var);

return $date;
}

/**
Expand Down
56 changes: 0 additions & 56 deletions src/Backend/Core/Installer/CoreInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,62 +66,6 @@ private function configureDefaultSettings(): void
$this->setSetting('Core', 'site_html_head', '');
$this->setSetting('Core', 'site_html_end_of_body', '');

// date & time
$this->setSetting('Core', 'date_format_short', 'j.n.Y');
$this->setSetting(
'Core',
'date_formats_short',
[
'j/n/Y',
'j-n-Y',
'j.n.Y',
'n/j/Y',
'n/j/Y',
'n/j/Y',
'd/m/Y',
'd-m-Y',
'd.m.Y',
'm/d/Y',
'm-d-Y',
'm.d.Y',
'j/n/y',
'j-n-y',
'j.n.y',
'n/j/y',
'n-j-y',
'n.j.y',
'd/m/y',
'd-m-y',
'd.m.y',
'm/d/y',
'm-d-y',
'm.d.y',
]
);
$this->setSetting('Core', 'date_format_long', 'l j F Y');
$this->setSetting(
'Core',
'date_formats_long',
[
'j F Y',
'D j F Y',
'l j F Y',
'j F, Y',
'D j F, Y',
'l j F, Y',
'd F Y',
'd F, Y',
'F j Y',
'D F j Y',
'l F j Y',
'F d, Y',
'D F d, Y',
'l F d, Y',
]
);
$this->setSetting('Core', 'time_format', 'H:i');
$this->setSetting('Core', 'time_formats', ['H:i', 'H:i:s', 'g:i a', 'g:i A']);

// number formats
$this->setSetting('Core', 'number_format', 'dot_nothing');
$this->setSetting(
Expand Down
75 changes: 75 additions & 0 deletions src/Backend/Core/Installer/Data/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4395,6 +4395,81 @@
<translation language="nl"><![CDATA[Bewaar mijn voorkeuren]]></translation>
<translation language="en"><![CDATA[Save my preferences]]></translation>
</item>
<item type="label" name="TimeAgoEmpty">
<translation language="en"><![CDATA[just now]]></translation>
<translation language="nl"><![CDATA[zojuist]]></translation>
<translation language="fr"><![CDATA[à l’instant]]></translation>
</item>
<item type="label" name="TimeAgoSecondSingular">
<translation language="en"><![CDATA[1 second ago]]></translation>
<translation language="nl"><![CDATA[1 seconde geleden]]></translation>
<translation language="fr"><![CDATA[il y a 1 seconde]]></translation>
</item>

<item type="label" name="TimeAgoSecondPlural">
<translation language="en"><![CDATA[%1$s seconds ago]]></translation>
<translation language="nl"><![CDATA[%1$s seconden geleden]]></translation>
<translation language="fr"><![CDATA[il y a %1$s secondes]]></translation>
</item>

<item type="label" name="TimeAgoMinuteSingular">
<translation language="en"><![CDATA[1 minute ago]]></translation>
<translation language="nl"><![CDATA[1 minuut geleden]]></translation>
<translation language="fr"><![CDATA[il y a 1 minute]]></translation>
</item>

<item type="label" name="TimeAgoMinutePlural">
<translation language="en"><![CDATA[%1$s minutes ago]]></translation>
<translation language="nl"><![CDATA[%1$s minuten geleden]]></translation>
<translation language="fr"><![CDATA[il y a %1$s minutes]]></translation>
</item>

<item type="label" name="TimeAgoHourSingular">
<translation language="en"><![CDATA[1 hour ago]]></translation>
<translation language="nl"><![CDATA[1 uur geleden]]></translation>
<translation language="fr"><![CDATA[il y a 1 heure]]></translation>
</item>

<item type="label" name="TimeAgoHourPlural">
<translation language="en"><![CDATA[%1$s hours ago]]></translation>
<translation language="nl"><![CDATA[%1$s uur geleden]]></translation>
<translation language="fr"><![CDATA[il y a %1$s heures]]></translation>
</item>

<item type="label" name="TimeAgoDaySingular">
<translation language="en"><![CDATA[1 day ago]]></translation>
<translation language="nl"><![CDATA[1 dag geleden]]></translation>
<translation language="fr"><![CDATA[il y a 1 jour]]></translation>
</item>
<item type="label" name="TimeAgoDayPlural">
<translation language="en"><![CDATA[%1$s days ago]]></translation>
<translation language="nl"><![CDATA[%1$s dagen geleden]]></translation>
<translation language="fr"><![CDATA[il y a %1$s jours]]></translation>
</item>

<item type="label" name="TimeAgoMonthSingular">
<translation language="en"><![CDATA[1 month ago]]></translation>
<translation language="nl"><![CDATA[1 maand geleden]]></translation>
<translation language="fr"><![CDATA[il y a 1 mois]]></translation>
</item>

<item type="label" name="TimeAgoMonthPlural">
<translation language="en"><![CDATA[%1$s months ago]]></translation>
<translation language="nl"><![CDATA[%1$s maanden geleden]]></translation>
<translation language="fr"><![CDATA[il y a %1$s mois]]></translation>
</item>

<item type="label" name="TimeAgoYearSingular">
<translation language="en"><![CDATA[1 year ago]]></translation>
<translation language="nl"><![CDATA[1 jaar geleden]]></translation>
<translation language="fr"><![CDATA[il y a 1 an]]></translation>
</item>

<item type="label" name="TimeAgoYearPlural">
<translation language="en"><![CDATA[%1$s years ago]]></translation>
<translation language="nl"><![CDATA[%1$s jaar geleden]]></translation>
<translation language="fr"><![CDATA[il y a %1$s ans]]></translation>
</item>
</Core>
</Frontend>
<Backend>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% extends 'Layout/Templates/base.html.twig' %}
{% import "Layout/Templates/macros.html.twig" as macro %}
{% import 'Layout/Templates/macros.html.twig' as macro %}

{% block actionbar %}
<div class="btn-toolbar pull-right">
<div class="btn-group" role="group">
{% if isAllowedAction('Data') %}
{{ macro.buttonIcon( geturl('data') ~ '&id=' ~ formId ~ '&start_date=' ~ filter.start_date ~ '&end_date=' ~ filter.end_date, 'list', 'lbl.BackToData'|trans|ucfirst) }}
{{ macro.buttonIcon(geturl('data') ~ '&id=' ~ formId ~ '&start_date=' ~ filter.start_date ~ '&end_date=' ~ filter.end_date, 'list', 'lbl.BackToData'|trans|ucfirst) }}
{% endif %}
</div>
</div>
Expand Down Expand Up @@ -41,7 +41,7 @@
<table class="table">
<tr>
<th>{{ 'lbl.SentOn'|trans|ucfirst }}:</th>
<td>{{ sentOn|spoondate }}</td>
<td>{{ sentOn|formatdatetime }}</td>
</tr>
</table>
</div>
Expand Down Expand Up @@ -71,8 +71,8 @@
<p>{{ 'msg.ConfirmDeleteData'|trans|ucfirst }}</p>
</div>
<div class="modal-footer">
{{ macro.buttonIcon('', 'times', 'lbl.Cancel'|trans|ucfirst, 'btn-default', { "data-dismiss":"modal", "type":"button" } ) }}
{{ macro.buttonIcon(geturl('mass_data_action') ~ '&action=delete&form_id=' ~ formId ~ '&id=' ~ id, 'trash', 'lbl.Delete'|trans|ucfirst, 'btn-danger' ) }}
{{ macro.buttonIcon('', 'times', 'lbl.Cancel'|trans|ucfirst, 'btn-default', {'data-dismiss': 'modal', type: 'button'}) }}
{{ macro.buttonIcon(geturl('mass_data_action') ~ '&action=delete&form_id=' ~ formId ~ '&id=' ~ id, 'trash', 'lbl.Delete'|trans|ucfirst, 'btn-danger') }}
</div>
</div>
</div>
Expand Down
Loading
Loading