Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searching the code there are still some strftimes present: #4398

Open
sreichel opened this issue Nov 29, 2024 · 5 comments
Open

Searching the code there are still some strftimes present: #4398

sreichel opened this issue Nov 29, 2024 · 5 comments

Comments

@sreichel
Copy link
Contributor

          Searching the code there are still some `strftimes` present:

Screen Shot 2024-11-26 at 18 45 26 PM

Originally posted by @boesbo in #2934 (comment)

@kiatng
Copy link
Contributor

kiatng commented Dec 3, 2024

It's not so straight forward to replace strftime(), which is from C lib, which format spec is also used in js\calendar\calendar.js.
We can consider this: https://github.com/alphp/strftime

@boesbo
Copy link
Contributor

boesbo commented Dec 3, 2024

It's not so straight forward to replace strftime(), which is from C lib, which format spec is also used in js\calendar\calendar.js. We can consider this: https://github.com/alphp/strftime

I think it is not necessary to add this library, but simply use the date function, with some precautions. I have little time now, but if there is no PR, as soon as I can I will do mine

@sreichel
Copy link
Contributor Author

sreichel commented Dec 4, 2024

We can consider to replace all date functions with https://github.com/briannesbitt/Carbon

@Hanmac
Copy link
Contributor

Hanmac commented Dec 5, 2024

What should we do about this?

class Mage_Adminhtml_Model_System_Config_Source_Date_Short
{
public function toOptionArray()
{
$arr = [];
$arr[] = ['label' => '', 'value' => ''];
$arr[] = ['label' => strftime('MM/DD/YY (%m/%d/%y)'), 'value' => '%m/%d/%y'];
$arr[] = ['label' => strftime('MM/DD/YYYY (%m/%d/%Y)'), 'value' => '%m/%d/%Y'];
$arr[] = ['label' => strftime('DD/MM/YY (%d/%m/%y)'), 'value' => '%d/%m/%y'];
$arr[] = ['label' => strftime('DD/MM/YYYY (%d/%m/%Y)'), 'value' => '%d/%m/%Y'];
return $arr;
}
}

The config source isn't used in Magento, and while we could change the label to not rely on strftime anymore,
we probably can't change the value in case the source is used somewhere else?

just mark the class as deprecated?

@kiatng
Copy link
Contributor

kiatng commented Dec 6, 2024

What should we do about this?

Mark it @deprecated and delete the file later. The output is:

 array(5) {
  [0] => array(2) {
    ["label"] => string(0) ""
    ["value"] => string(0) ""
  }
  [1] => array(2) {
    ["label"] => string(19) "MM/DD/YY (12/06/24)"
    ["value"] => string(8) "%m/%d/%y"
  }
  [2] => array(2) {
    ["label"] => string(23) "MM/DD/YYYY (12/06/2024)"
    ["value"] => string(8) "%m/%d/%Y"
  }
  [3] => array(2) {
    ["label"] => string(19) "DD/MM/YY (06/12/24)"
    ["value"] => string(8) "%d/%m/%y"
  }
  [4] => array(2) {
    ["label"] => string(23) "DD/MM/YYYY (06/12/2024)"
    ["value"] => string(8) "%d/%m/%Y"
  }
}

Which looks like the options in a dropdown for configuring date formatting, which is specific for strftime(). So, if we mark it as deprecated, there is no need to change anything. We can delete it when PHP throws an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants