/// <summary> /// Converts string to number /// </summary> /// <param name="spec">The conversion spec</param> /// <param name="val">The string value to convert</param> /// <returns></returns> public static object Convert_String_To_Time(ConvertSpec spec, object obj) { var val = (LString)obj; var txt = val.Value.ToLower(); var result = DateTimeTypeHelper.ParseTime(txt); if (!result.Item2) { return(LObjects.Null); } return(new LTime(result.Item1)); }
/// <summary> /// Converts from c# datatypes to fluentscript datatypes inside /// </summary> /// <param name="val"></param> public static LObject ConvertToLangValue(LType ltype, object val) { if (val == null) { return(LObjects.Null); } if (ltype == LTypes.Number) { return(new LNumber(Convert.ToDouble(val))); } if (ltype == LTypes.String) { return(new LString(Convert.ToString(val))); } if (ltype == LTypes.Date) { return(new LDate(Convert.ToDateTime(val))); } if (ltype == LTypes.Time) { var valText = Convert.ToString(val); var result = DateTimeTypeHelper.ParseTime(valText); var time = result.Item1; return(new LTime(time)); } if (ltype == LTypes.Bool) { return(new LBool(Convert.ToBoolean(val))); } return(LObjects.Null); }