Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-61027

User profile field datetime with persian calendar

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3.3, 3.4
    • Fix Version/s: 3.3.5, 3.4.2
    • Component/s: Calendar
    • Labels:
    • Testing Instructions:
      Hide

      Initial setup

      1. Install the Persian calendar plugin from https://moodle.org/plugins/calendartype_jalali
      2. Go to Site administration > Users > User profile fields and create a new "Date/Time" profile field
      3. In the "Creating a new 'Date/Time' profile field" form, set the "start year" field to 1900 and set the "end date" field to 2050
      4. Also name the new profile field you are creating as "Test Date"

      Post setup instructions

      1. Log in as a user
      2. go to user preferences and change "preferred calendar" to the Persian calendar
      3. Edit your profile and set the value of "Test Date" to "2 Bahman 1396"
      4. Save the form
      5. Go to edit profile page again and confirm that the value of "Test Date" field is "2 Bahman 1396"
      Show
      Initial setup Install the Persian calendar plugin from https://moodle.org/plugins/calendartype_jalali Go to Site administration > Users > User profile fields and create a new "Date/Time" profile field In the "Creating a new 'Date/Time' profile field" form, set the "start year" field to 1900 and set the "end date" field to 2050 Also name the new profile field you are creating as "Test Date" Post setup instructions Log in as a user go to user preferences and change "preferred calendar" to the Persian calendar Edit your profile and set the value of "Test Date" to "2 Bahman 1396" Save the form Go to edit profile page again and confirm that the value of "Test Date" field is "2 Bahman 1396"
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull from Repository:
    • Pull 3.4 Branch:
    • Pull Master Branch:
      MDL-61027-master

      Description

      • First I install persian calendar
      • I add a custom profile field to get Date of birth of users
      • In this case users can pick a date (solar date)
      • when a user wants to save profile settings
      • date changes automatically
      • and saves a negative number for time in DB

       

      But I found my answer . the profilefield_datetime  plugin uses min and max date based on Gregorian calendar . I fixed my problem by convert to Gregorian date before processing date :

      In profilefield_datetime and in field.class.php and in "edit_save_data_preprocess" method I replaced This line :

       

      $datetime = userdate($datetime, '%Y-%m-%d-%H-%M-%S');

       

      by

       

      $datetime = date('Y-m-d-H-m-s', $datetime);

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                19/Mar/18

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h