YAFLogo

coral
  • coral
  • 72% (Friendly)
  • YAF Lover Topic Starter
9 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
9 years ago
Just as a complementary note, Persian date is saved in profiles but not displayed!
coral
  • coral
  • 72% (Friendly)
  • YAF Lover Topic Starter
9 years ago
where is it not displayed?

I can see it in profile summary and hovercard.
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button