Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-16625

Import Contacts birth_date broken for dd/mm/yyyy

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.13, 4.4.15, 4.6.4
    • Fix Version/s: None
    • Component/s: Core CiviCRM
    • Labels:
    • Documentation Required?:
      None

      Description

      If I'm importing contacts from CSV, for example in the form:
      firstname,lastname,dob,email
      Testone,DK,25/12/2000,testone@example.com

      with dd/mm/yyyy selected at the bottom of the data source page, the created contact's birth_date actually gets set to 1st Jan 1970. If I import a contact with a date string that is valid the US and UK way round, even though I select the UK way, it gets imported as if it was the US way.

      • If I have the date 25/12/2008, and tell it I'm importing in UK date format, it doesn't flag it as an error but it gets recorded as 1/1/1970.
      • If I tell it I'm importing in US format, it is correctly flagged as an error as the US would write 12/25/2008.
      • If I give it 12/25/2008 and tell it I'm importing in UK format, it is correctly flagged as an error.
      • If I tell it I'm importing that in US format it works.

      Replicated on 4.4 and 4.6 demo.

      Putting watchdogs on pre hooks, and at the beginning of CRM_Contact_Import_Parser_Contact::createContact, revealed that the date was being submitted for contact creation still in the localised format, not as yyyymmdd. The API doesn't complain, however, if the US format is used, so that's why date strings that are valid both ways round still go through as the US format. I believe (but have not checked) that the same will be true for the deceased date.

      I have tracked this down to a misplaced curly bracket in CRM_Contact_Import_Parser_Contact::formatCommonData. I now get the dates submitted for contact creation as yyyymmdd. I will submit PRs this afternoon.

        Attachments

          Activity

            People

            • Assignee:
              jitendra.purohit Jitendra Purohit
              Reporter:
              DaveFF David Knoll
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: