YAFLogo

coral
  • coral
  • 72% (Friendly)
  • YAF Lover Topic Starter
8 years ago
To conclude, the cause of problem was the use of Farsi calendar, for whatever reason it couldn't get the format right and therefore not able to convert it to Gergorian calendar for saving in db. I used my own date converter and problem is solved.

As it also didn't inform user of invalid date entry I also added date validator to controls/EditUsersProfile.asx.cs.

/// <summary>
        /// The update profile_ click.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        protected void UpdateProfile_Click([NotNull] object sender, [NotNull] EventArgs e)
        {
            if(this.Birthday.Text.IsSet() && !isValidDate(this.Birthday.Text)){
                this.PageContext.AddLoadMessage(this.GetText("PROFILE", "BAD_DATE"), MessageTypes.Warning);
                return;
            }
.....


private bool isValidDate(string dateStr)
        {
            if (this.Get<YafBoardSettings>().UseFarsiCalender)
            {
                try
                {
                   persianDate = new PersianDate(this.Birthday.Text);
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            else
            {
                DateTime dt;
                return DateTime.TryParse(dateStr, out dt);
            }
        }

And I added the BAD_DATE tag to PROFILE page of language files.

herman_herman
8 years ago
Just as a complementary note, Persian date is saved in profiles but not displayed!
coral
  • coral
  • 72% (Friendly)
  • YAF Lover Topic Starter
8 years ago
where is it not displayed?

I can see it in profile summary and hovercard.