Skip to content

Commit

Permalink
Update I18nDateTime.php & lang files for DateTime format
Browse files Browse the repository at this point in the history
Update I18nDateTime.php to match the DateTime format syntax
Replace old strftime format with consistent DateTime format
  • Loading branch information
AntonyThorpe committed Feb 14, 2025
1 parent 7e1b330 commit 5cb2567
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lang/da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ da:
Change: Ændring
Customer: Kunde
Date: Dato
DateFormatNice: '%d/%m/%Y'
DateTimeFormatNice: '%d/%m/%Y %H:%i%s'
DateFormatNice: 'd/m/Y'
DateTimeFormatNice: 'd/m/Y H:i:s'
DateTimeFormatNice24: 'd/m/Y H:i'
DevToolsTitle: 'SilverShop udviklingsværktøjer'
Edit: Rediger
Expand Down
4 changes: 2 additions & 2 deletions lang/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ de:
Change: Ändern
Customer: Kunde
Date: Datum
DateFormatNice: '%d.%m.%Y'
DateTimeFormatNice: '%d.%m.%Y %H:%M'
DateFormatNice: 'd.m.Y'
DateTimeFormatNice: 'd.m.Y H:i'
DateTimeFormatNice24: 'd.m.Y H:i'
DevToolsTitle: 'Shop Entwickler Tools'
Edit: Bearbeiten
Expand Down
4 changes: 2 additions & 2 deletions lang/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ en:
Change: Change
Customer: Customer
Date: Date
DateFormatNice: '%m/%d/%G'
DateTimeFormatNice: '%m/%d/%G %I:%M%p'
DateFormatNice: 'm/d/Y'
DateTimeFormatNice: 'm/d/Y h:i A'
DateTimeFormatNice24: 'd/m/Y H:i'
DevToolsTitle: 'Shop Development Tools'
Edit: Edit
Expand Down
4 changes: 2 additions & 2 deletions lang/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ fr:
Change: Change
Customer: Client
Date: Date
DateFormatNice: '%m/%d/%G'
DateTimeFormatNice: '%m/%d/%G %I:%M%p'
DateFormatNice: 'm/d/Y'
DateTimeFormatNice: 'm/d/Y h:i A'
DateTimeFormatNice24: 'j/m/A H:i'
DevToolsTitle: 'Rechercher des outils de développeur'
Edit: Éditer
Expand Down
4 changes: 2 additions & 2 deletions lang/hr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ hr:
Change: Promjeni
Customer: Kupac
Date: Datum
DateFormatNice: '%m/%d/%G'
DateTimeFormatNice: '%m/%d/%G %I:%M%p'
DateFormatNice: 'd/m/Y'
DateTimeFormatNice: 'd/m/Y H:i'
DateTimeFormatNice24: 'd/m/Y H:i'
Edit: Uredi
Quantity: Količina
Expand Down
4 changes: 2 additions & 2 deletions lang/nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ nb:
Change: Endre
Customer: Kunde
Date: Dato
DateFormatNice: '%m/%d/%G'
DateTimeFormatNice: '%m/%d/%G %I:%M%p'
DateFormatNice: 'm/d/Y'
DateTimeFormatNice: 'm/d/Y h:i A'
DateTimeFormatNice24: 'd/m/Y H:i'
DevToolsTitle: 'Vis SilverShop utviklingsverktøy'
Edit: Endre
Expand Down
4 changes: 2 additions & 2 deletions lang/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ nl:
Change: Pas aan
Customer: Klant
Date: Datum
DateFormatNice: '%d-%m-%G'
DateTimeFormatNice: '%d-%m-%G %H:%M'
DateFormatNice: 'd-m-Y'
DateTimeFormatNice: 'd-m-Y H:i'
DateTimeFormatNice24: 'd/m/Y H:i'
DevToolsTitle: 'Winkel ontwikkelgereedschappen'
Edit: Bewerk
Expand Down
4 changes: 2 additions & 2 deletions lang/nn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ nn:
Change: Endre
Customer: Kunde
Date: Dato
DateFormatNice: '%m/%d/%G'
DateTimeFormatNice: '%m/%d/%G %I:%M%p'
DateFormatNice: 'm/d/Y'
DateTimeFormatNice: 'm/d/Y h:i A'
DateTimeFormatNice24: 'd/m/Y H:i'
DevToolsTitle: 'Vis utviklingsverktøy'
Edit: Endre
Expand Down
19 changes: 14 additions & 5 deletions src/ORM/FieldType/I18nDatetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,33 @@ class I18nDatetime extends DBDatetime
{
/**
* Returns the datetime in the format given in the lang file
* 'SilverShop\Generic.DateTimeFormatNice'. Defaults to '%m/%d/%G %I:%M%p'
* 'SilverShop\Generic.DateTimeFormatNice'. Defaults to 'm/d/Y h:i A'
*
* @return string|null
*/
public function Nice()
{
if ($this->value) {
return date_format(date_create($this->getTimestamp()), _t('SilverShop\Generic.DateTimeFormatNice', '%m/%d/%G %I:%M%p'));
return date_format(
date_create($this->getTimestamp()),
_t('SilverShop\Generic.DateTimeFormatNice', 'm/d/Y h:i A')
);
}
}

/**
* Returns the date in the format given in the lang file.
* 'SilverShop\Generic.DateFormatNice'. Defaults to '%m/%d/%G'
* 'SilverShop\Generic.DateFormatNice'. Defaults to 'm/d/Y'
*
* @return string|null
*/
public function NiceDate()
{
if ($this->value) {
return date_format(date_create($this->getTimestamp()), _t('SilverShop\Generic.DateFormatNice', '%m/%d/%G'));
return date_format(
date_create($this->getTimestamp()),
_t('SilverShop\Generic.DateFormatNice', 'm/d/Y')
);
}
}

Expand All @@ -43,6 +49,9 @@ public function NiceDate()
*/
public function Nice24()
{
return date(_t('SilverShop\Generic.DateTimeFormatNice24', 'd/m/Y H:i'), $this->getTimestamp());
return date(
_t('SilverShop\Generic.DateTimeFormatNice24', 'd/m/Y H:i'),
$this->getTimestamp()
);
}
}

0 comments on commit 5cb2567

Please sign in to comment.