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

Create or Edit Membership - incorrect date parsing when using dd/mm/yyyy format

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.1
    • Fix Version/s: 3.4.3
    • Component/s: CiviMember, Core CiviCRM
    • Labels:
      None

      Description

      In version 3.4.1 (was working in previous) there is a bug when the civicrm is configured with dd/mm/yyyy date formats

      1. When you edit an existing membership (when creating doesn't show this bug) and set any date (Member Since, Start Date and/or End Date) with the day higher than 12 (24/05/2001, 13/12/ 2011, etc..) and save the changes, you'll receive error messages from the validator as "Start date must be the same or later than Member since", or "Start date must be set if end date is set.", etc.. depends the situation. When of course, the conditions match and they shouldn't appear.

      2. Looks like getMembershipStatusByDate doesn't handle dd/mm/yy either, so you get a formRule error if you set Member Since Date something like '25/05/2011' (day grater than 12) and set same date for Start Date. This error msg will be displayed (it shouldn't):
      There is no valid Membership Status available for selected membership dates.

      Additional details in this forum post:
      http://forum.civicrm.org/index.php/topic,20208.0.html

      After researching I found that the dates are not being parsed correctly.
      in CRM_Member_Form_Membership, line 627
      $startDate = CRM_Utils_Date::processDate( $params['start_date'] );

      if $startDate is something like '21/04/20011', CRM_Utils_Date::processDate returns 19700101010000

      the same for any date variable with the day higher than 12, obviously, i figured it out that it was an error in the parsing function.

      Comparing CRM_Utils_Date::processDate() functions between versions 3.3.3 (the previous version I had installed and was working this issue ) and 3.4.1, there is a difference, in version 3.4.1 there isn't this part of code:

      if ( $inputFormat == 'dd/mm/yy' ) {
      $date = str_replace( '/', '-', $date );
      }

      adding this part again to CRM_Utils_Date::processDate() in v 3.4.1, it works for edit. However adding that in CRM_Utils_Date::processDate() wasn't a solution, because the date is past as argument in different formats. Depends if it's editing or creating a membership.

        Attachments

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              sluc23 Luciano Spiegel
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 2 hours Original Estimate - 2 hours
                2h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h