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

new Zend_Date($zendDateInstance, null, 'zh_TW') causing exception #441

Open
xqiu opened this issue Sep 20, 2024 · 1 comment
Open

new Zend_Date($zendDateInstance, null, 'zh_TW') causing exception #441

xqiu opened this issue Sep 20, 2024 · 1 comment

Comments

@xqiu
Copy link

xqiu commented Sep 20, 2024

Add the following unit tests to tests/Zend/Date/DateObjectTest.php,

    public function testNewDateLocaleTW()
    {
        // a mimic of the way that openmage calls the code in zh_TW locale, from [app/code/core/Mage/Adminhtml/Controller/Report/Abstract.php](https://github.com/OpenMage/magento-lts/blob/main/app/code/core/Mage/Adminhtml/Controller/Report/Abstract.php), function _showLastExecutionTime
        $date = new Zend_Date("2020-01-13 10:00:03", "yyyy-MM-dd HH:mm:ss", null);
        $this->assertTrue($date instanceof Zend_Date);
        $date2 = new Zend_Date($date, null, 'zh_TW');
        $this->assertTrue($date2 instanceof Zend_Date);
    }

    public function testNewDateLocaleTWDirect()
    {
        //minimal bug repo
        $dateString = '2020年1月13日 上午1:00:03';
        $format = 'y年M月d日 ah:mm:ss';
        $this->assertTrue(new Zend_Date($dateString, $format, 'zh_TW') instanceof Zend_Date);
    }

Run the unit test:

There were 2 errors:

1) Zend_Date_DateObjectTest::testNewDateLocale1
Zend_Date_Exception: Unable to parse date '2020年1月13日 上午1:00:03' using 'y年M月d日 ah:mm:ss' (M <> d)

/mnt/e/github/zf1-future/library/Zend/Date.php:2540
/mnt/e/github/zf1-future/library/Zend/Date.php:1002
/mnt/e/github/zf1-future/library/Zend/Date.php:197
/mnt/e/github/zf1-future/tests/Zend/Date/DateObjectTest.php:670

Caused by
Zend_Locale_Exception: Unable to parse date '2020年1月13日 上午1:00:03' using 'y年M月d日 ah:mm:ss' (M <> d)

/mnt/e/github/zf1-future/library/Zend/Locale/Format.php:1080
/mnt/e/github/zf1-future/library/Zend/Locale/Format.php:1175
/mnt/e/github/zf1-future/library/Zend/Date.php:2506
/mnt/e/github/zf1-future/library/Zend/Date.php:1002
/mnt/e/github/zf1-future/library/Zend/Date.php:197
/mnt/e/github/zf1-future/tests/Zend/Date/DateObjectTest.php:670

2) Zend_Date_DateObjectTest::testNewDateLocale2
Zend_Date_Exception: Unable to parse date '2020年1月13日 上午10:00:03' using 'y年M月d日 ah:mm:ss' (M <> d)

/mnt/e/github/zf1-future/library/Zend/Date.php:2540
/mnt/e/github/zf1-future/library/Zend/Date.php:1002
/mnt/e/github/zf1-future/library/Zend/Date.php:197
/mnt/e/github/zf1-future/tests/Zend/Date/DateObjectTest.php:677

Caused by
Zend_Locale_Exception: Unable to parse date '2020年1月13日 上午10:00:03' using 'y年M月d日 ah:mm:ss' (M <> d)

/mnt/e/github/zf1-future/library/Zend/Locale/Format.php:1080
/mnt/e/github/zf1-future/library/Zend/Locale/Format.php:1175
/mnt/e/github/zf1-future/library/Zend/Date.php:2506
/mnt/e/github/zf1-future/library/Zend/Date.php:1002
/mnt/e/github/zf1-future/library/Zend/Date.php:197
/mnt/e/github/zf1-future/tests/Zend/Date/DateObjectTest.php:677

I'm using PHP 8.1.2

@sreichel
Copy link

Nice.

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

No branches or pull requests

2 participants