Exemplo n.º 1
0
 public void ConvertDateTimeConstructorTest1()
 {
     DateTimeTypes dataType = new DateTimeTypes(); // TODO: Initialize to an appropriate value
     Expression expression = null; // TODO: Initialize to an appropriate value
     ConvertDateTime target = new ConvertDateTime(dataType, expression);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Exemplo n.º 2
0
        static ReporterParameter CreateDateTime(this ReporterParameter param, DateTimeTypes dateTimeType, string displayFormat, bool roller = false)
        {
            param.ValueType = ParameterValueType.DateTime;

            string typeString       = "";
            string defDisplayFormat = "";

            switch (dateTimeType)
            {
            default:
            case DateTimeTypes.Date:
                typeString       = "date";
                defDisplayFormat = "dd.MM.yyyy";
                break;

            case DateTimeTypes.Time:
                typeString       = "time";
                defDisplayFormat = "HH:mm";
                break;

            case DateTimeTypes.DateTime:
                typeString       = "datetime";
                defDisplayFormat = "dd.MM.yyyy HH:mm";
                break;
            }
            if (displayFormat.isNullOrWhiteSpace())
            {
                displayFormat = defDisplayFormat;
            }

            param.Html = $@"<div class='option'><span>parameter_text</span><div id='parameter_name'></div></div>";
            param.Js   = @"
                <script>$(function() {
                    $('#parameter_name').dxDateBox({
                        type: '" + typeString + @"',
                        displayFormat:'" + displayFormat + @"',
                        value: new Date(),
                        onValueChanged: function (e) {
                            var previousValue = e.previousValue;
                            var newValue = e.value;
                            jQuery.data(document.body, 'parameter_name_value', dateToString(e.value));
                        }
                    });
                    jQuery.data(document.body, 'parameter_name_value', dateToString(getDate('parameter_name').option('value')));
                    }
                    )
                </script>
                ";
            return(param.ReplaceParamTextName());
        }
Exemplo n.º 3
0
 public DateTimeMsSqlColumnType(DateTimeTypes dateTimeTypes)
 {
     DateTimeType = dateTimeTypes;
 }
Exemplo n.º 4
0
        //The conversion of the given non-numerical value to DateTime would be different depending upon the given secondary type (i.e., DateTimeTypes). This function performs the corresponding analysis
        private double valueFromDateTimeType(DateTime curDateTime, DateTimeTypes curType)
        {
            double outVal = 0.0;

            if (curType == DateTimeTypes.Time)
            {
                outVal = (double)(10000 * curDateTime.Hour + 100 * curDateTime.Minute + curDateTime.Second);
            }
            else if (curType == DateTimeTypes.Year)
            {
                outVal = (double)curDateTime.Year;
            }
            else if (curType == DateTimeTypes.Month)
            {
                outVal = (double)curDateTime.Month;
            }
            else if (curType == DateTimeTypes.Weekday)
            {
                outVal = (double)((int)curDateTime.DayOfWeek);
            }
            else if (curType == DateTimeTypes.Day)
            {
                outVal = (double)curDateTime.Day;
            }

            return outVal;
        }
Exemplo n.º 5
0
        //Function called to adapt the given column to match the DateTime type
        private Input updateTime(Input curInput, DateTimeTypes curType)
        {
            for (int i = 0; i < curInput.vals2.Count; i++)
            {
                if (curInput.vals.Count - 1 < i) curInput.vals.Add(0.0);
                DateTime tempVal = new DateTime(1900, 1, 1);

                if (DateTime.TryParse(curInput.vals2[i], Common.curCulture, System.Globalization.DateTimeStyles.None, out tempVal))
                {
                    double newVal = valueFromDateTimeType(tempVal, curType);
                    if (!curInput.conversionDict.ContainsKey(curInput.vals2[i])) curInput.conversionDict.Add(curInput.vals2[i], newVal);
                    curInput.vals[i] = newVal;
                }
                else
                {
                    curInput.wrongRowsCount = curInput.wrongRowsCount + 1;
                }
            }

            return curInput;
        }
        private string DateTimeAdd(string input, string pattern, DateTimeTypes dtType)
        {
            //Include a percent ("%") format specifier before the single custom date and time specifier. like d,m e.t.c
            //Bellow creates two regex groups, one of them contains the values in the middle (.*)
            Match innerMatch = Regex.Match(pattern, @"%Add[MonthsDayYer]+\(([-]?\d+,.*)\)%");

            if (innerMatch.Success == false)
            {
                throw new ArgumentException($"No match for regex {pattern}", "DateTimeAdd");
            }

            char[] delimiterChar = { ',' };

            string innerValue = String.Empty;


            foreach (Group item in innerMatch.Groups)
            {
                if (item.Value.StartsWith("%Add") == false && item.Success == true)  //Success == false = empty values
                {
                    innerValue = item.Value;

                    string[] values = innerValue.Split(delimiterChar, StringSplitOptions.RemoveEmptyEntries);

                    if (values.Count() != 2)
                    {
                        return(input.Replace(innerMatch.Value, String.Empty));
                    }

                    try
                    {
                        string dateformat = String.Empty;

                        switch (dtType)
                        {
                        case DateTimeTypes.Day:
                            long days = long.Parse(values[0]);
                            dateformat = DateTime.Now.AddDays(days).ToString(values[1]);
                            break;

                        case DateTimeTypes.Month:
                            int months = int.Parse(values[0]);
                            dateformat = DateTime.Now.AddMonths(months).ToString(values[1]);
                            break;

                        case DateTimeTypes.Year:
                            int years = int.Parse(values[0]);
                            dateformat = DateTime.Now.AddYears(years).ToString(values[1]);
                            break;
                        }

                        input = input.Replace(innerMatch.Value, dateformat);
                    }
                    catch (System.FormatException fe)
                    {
                        throw new Exception("Invalid dateformat " + innerMatch.Value, fe);
                    }
                }
            }



            return(input);
        }