YAFLogo

bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer Topic Starter
13 years ago
During installation on a server with a different culture strings like

.5">(GMT+3:30) Tehran

in english.xml(default)

fail.

Decimal separator is culture specific. For example this works in some cultures

,5">(GMT+3:30) Tehran

The error occurs here:

Localization.cs :45

decimal hours = Convert.ToDecimal( node.Attributes["tag"].Value.Replace( "GMT", "" ) );

Sponsor

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
13 years ago
Not sure the best way to handle this... Any suggestions?
bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer Topic Starter
13 years ago
	 
decimal hours =0;
			try 
	                    {	        
		               hours = Convert.ToDecimal( node.Attributes["tag"].Value.Replace( "GMT", "" ));
	                    }
                    catch (FormatException ex)
                         {          
            hours = Convert.ToDecimal(node.Attributes["tag"].Value.Replace(".", ",").Replace("GMT", ""));
                         }
bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer Topic Starter
13 years ago
The bug still in svn.

/YAF.Classes.Utils/StaticData.cs:46

I think simple replacement for

decimal hours=Decimal.Parse(node.Attributes["tag"].Value.Replace("GMT", ""), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo);

solves the problem for all cultures.

nordic
  • nordic
  • 92% (Exalted)
  • YAF Lover
13 years ago
bbobb wrote:

The bug still in svn.

/YAF.Classes.Utils/StaticData.cs:46

I think simple replacement for

decimal hours=Decimal.Parse(node.Attributes["tag"].Value.Replace("GMT", ""), System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo);

solves the problem for all cultures.

Not working :(

This is error :

Quote:

[FormatException: Input string was not in a correct format.]

System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7471335

System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) +146

YAF.Classes.Utils.YafStaticData.TimeZones(YafLocalization localization) +351

YAF.Classes.Utils.YafStaticData.TimeZones() +24

YAF.Pages.register.Page_Load(Object sender, EventArgs e) +1064

System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14

System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35

System.EventHandler.Invoke(Object sender, EventArgs e) +0

System.Web.UI.Control.OnLoad(EventArgs e) +99

System.Web.UI.Control.LoadRecursive() +50

System.Web.UI.Control.LoadRecursive() +141

System.Web.UI.Control.LoadRecursive() +141

System.Web.UI.Control.LoadRecursive() +141

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

nordic
  • nordic
  • 92% (Exalted)
  • YAF Lover
13 years ago
Please, help 😞
nordic
  • nordic
  • 92% (Exalted)
  • YAF Lover
13 years ago
gcapnias
  • gcapnias
  • 50.6% (Neutral)
  • YAF Forumling
13 years ago
This should work:


	decimal hours = 0; 

	try
	{
		hours = Convert.ToDecimal(node.Attributes["tag"].Value.Replace("UTC", "").Replace("GMT", ""), new System.Globalization.CultureInfo("en-US").NumberFormat);
	}
	catch ( FormatException ex )
	{
		hours = Convert.ToDecimal(node.Attributes["tag"].Value.Replace(",", ".").Replace("UTC", "").Replace("GMT", ""), new System.Globalization.CultureInfo("en-US").NumberFormat);
	}

George J.

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
13 years ago
fixed in latest.