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

Admin date of birth doesn't factor in user locale set #27027

Closed
extroniks opened this issue Feb 26, 2020 · 23 comments
Closed

Admin date of birth doesn't factor in user locale set #27027

extroniks opened this issue Feb 26, 2020 · 23 comments
Assignees
Labels
Component: Admin Component: Customer Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reported on 2.3.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@extroniks
Copy link

Preconditions (*)

  1. Magento 2.3.4 (but probably on previous versions also)
  2. Login to admin
  3. Have locale set to en_GB (UK) for the user

Steps to reproduce (*)

  1. Edit a customer
  2. Select a date of birth after 12th of a month this year

Expected result (*)

  1. Date of birth is valid, you can save the customer

Actual result (*)

  1. Validation error happens "The Date of Birth should not be greater than today" because instead of DD/MM/YYYY the date is treated as MM/DD/YYYY

Here is a small composer patch I wrote for this:

--- a/view/base/web/js/lib/validation/rules.js
+++ b/view/base/web/js/lib/validation/rules.js
@@ -1069,12 +1069,12 @@ define([
             $.mage.__('This link is not allowed.')
         ],
         'validate-dob': [
-            function (value) {
+            function (value, param, params) {
                 if (value === '') {
                     return true;
                 }

-                return moment(value).isBefore(moment());
+                return moment.utc(value, params.dateFormat).isSameOrBefore(moment.utc());
             },
             $.mage.__('The Date of Birth should not be greater than today.')
         ]
--
2.17.1
@m2-assistant
Copy link

m2-assistant bot commented Feb 26, 2020

Hi @extroniks. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@extroniks do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 26, 2020
@extroniks
Copy link
Author

@magento give me 2.4-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @extroniks. Thank you for your request. I'm working on Magento 2.4-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @extroniks, here is your Magento instance.
Admin access: https://i-27027-2-4-develop.instances.magento-community.engineering/admin_200b
Login: 38c1e601 Password: 0091173fa523
Instance will be terminated in up to 3 hours.

@extroniks
Copy link
Author

Reproduced on 2.4:
image

@sudheers-kensium sudheers-kensium self-assigned this Feb 26, 2020
@m2-assistant
Copy link

m2-assistant bot commented Feb 26, 2020

Hi @sudheers-kensium. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@sudheers-kensium sudheers-kensium added Component: Admin Component: Customer Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Feb 26, 2020
@ghost ghost unassigned sudheers-kensium Feb 26, 2020
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Feb 26, 2020
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @sudheers-kensium
Thank you for verifying the issue. Based on the provided information internal tickets MC-31918 were created

Issue Available: @sudheers-kensium, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@webalvk
Copy link

webalvk commented Feb 26, 2020

Hi I'm having the same issue with local set to pt_br and magento 2.3.3, is there a fix yet?

@extroniks
Copy link
Author

extroniks commented Feb 26, 2020

@webalvk

Hi I'm having the same issue with local set to pt_br and magento 2.3.3, is there a fix yet?

You can use the patch I wrote, it should work fine, if you need the whole patch I can forward you one until an official fix is done.

@webalvk
Copy link

webalvk commented Feb 26, 2020

@extroniks

@webalvk

Hi I'm having the same issue with local set to pt_br and magento 2.3.3, is there a fix yet?

You can use the patch I wrote, it should work fine, if you need the whole patch I can forward you one until an official fix is done.

Thanks for fast replying... I'm not a programmer and i don't know how to apply this fix, could you provide me instructions, please?

I tried creating a file dob-fix-patch.patch with your fix.... and then run "git apply patches/composer/dob-fix-patch.patch" but I get an error: "error: corrupt patch at line 12"

My email: web@alvk.com.br
Thanks

@nuzil
Copy link
Contributor

nuzil commented Feb 28, 2020

@extroniks maybe you want to provide PR with the fix?

@deep701
Copy link

deep701 commented Feb 29, 2020

@magento give me 2.4-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @deep701. Thank you for your request. I'm working on Magento 2.4-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @deep701, here is your Magento instance.
Admin access: https://i-27027-2-4-develop.instances.magento-community.engineering/admin_7eeb
Login: ef55fb98 Password: 79769dc1fcf5
Instance will be terminated in up to 3 hours.

@deep701
Copy link

deep701 commented Feb 29, 2020

@magento Unable to reproduce in latest instance.
screenshot-i-27027-2-4-develop instances magento-community engineering-2020 02 29-14_19_24

@keval123
Copy link

@magento give me 2.3.4-develop instance

@extroniks
Copy link
Author

@deep701 You need to select February after 12th. From your screenshot the date format is mm/dd/YYYY, issue happens when format is dd/mm/YYYY.

@nuzil
Will see if I get the time during this week for a proper pull request / fix.

@extroniks
Copy link
Author

@webalvk
Will send you the proper composer patch these days.

@vitmarks
Copy link

vitmarks commented Mar 2, 2020

Hello same issue here, can you provide me also with the fix?

@sergiy-v sergiy-v self-assigned this Mar 3, 2020
@m2-assistant
Copy link

m2-assistant bot commented Mar 3, 2020

Hi @sergiy-v. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


@NeilofSteel
Copy link

NeilofSteel commented Mar 10, 2020

@extroniks Solution not working for me... wasn't there another fix few days ago? I used another fix which worked for me but I can't find it

I tried your changes in /vendor/magento/module-ui/view/base/web/js/lib/validation/rules.js

@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Mar 12, 2020
@magento-engcom-team
Copy link
Contributor

Hi @extroniks. Thank you for your report.
The issue has been fixed in #27149 by @sergiy-v in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.0 release.

@bcok22
Copy link

bcok22 commented Mar 22, 2020

overwrite

vendor/magento/module-customer/view/frontend/web/js/validation.js in your theme

and change

return moment(value, ["dd.MM.Y"]).isBefore(moment());

to

return moment(value, ["MM.dd.Y"]).isBefore(moment());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Admin Component: Customer Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reported on 2.3.4 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

No branches or pull requests