General developer forum

User profile fields date picker with persian calendar

 
Picture of Amin Farajzadeh
User profile fields date picker with persian calendar
 

I`m using Persian calendar.

When I add a new User profile field of type Date/Time  . when I want to pick a date in Edit profile page it automatically changes after save .

I`m using moodle 3.3 and calander version :

$plugin->version = 2017030200;
$plugin->requires = 2013110100;
$plugin->component = 'calendartype_jalali';
$plugin->release = '1.1 for Moodle 2.6 onwards';
$plugin->dependencies = array('calendartype_gregorian' => ANY_VERSION);
$plugin->maturity = MATURITY_STABLE;


 
Average of ratings: -
Picture of David Mudrák
Re: User profile fields date picker with persian calendar
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersPlugins guardiansTestersTranslators

Sorry I don't get what particular problem you have? Can you elaborate a but and provide steps to reproduce together with expected result and actual behaviour? Thanks.

 
Average of ratings: -
Picture of Amin Farajzadeh
Re: User profile fields date picker with persian calendar
 
  • 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);


 
Average of ratings: -
Picture of David Mudrák
Re: User profile fields date picker with persian calendar
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersPlugins guardiansTestersTranslators

Hmm, so that sounds like a bug in that profile field code. Have you checked the tracker if it has been reported, and can you eventually report it as a new issue? Thanks.

 
Average of ratings: -
Picture of Amin Farajzadeh
Re: User profile fields date picker with persian calendar
 
I reported this bug: https://tracker.moodle.org/browse/MDL-61027

I hope it can help you.
 
Average of ratings: -