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

User profile field datetime with persian calendar

XMLWordPrintable

    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • MOODLE_33_STABLE, MOODLE_34_STABLE
    • MDL-61027-master
    • 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"

      • 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);

            rezaie9 Shamim Rezaie
            fazelfaraji Amin Farajzadeh
            Simey Lameze Simey Lameze
            David Monllaó David Monllaó
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.