Example #1
0
        public void TryCompare_Years_Equal_Expected_One_Years()
        {
            _outputType = "Years";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "1");
        }
Example #2
0
        public void TryCompare_Weeks_Equal_Expected_One_Weeks()
        {
            _input2     = "2011/06/12 08:20:30:123 AM";
            _outputType = "Weeks";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "1");
        }
Example #3
0
        public void TryCompare_Minutes_One_Over_Expected_One_Minutes()
        {
            _input2     = "2011/06/05 08:21:30:124 AM";
            _outputType = "Minutes";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "1");
        }
Example #4
0
        public void TryCompare_Seconds_Negative_Expected_NegativeOne_Seconds()
        {
            _input2     = "2011/06/05 08:20:29:123 AM";
            _outputType = "Seconds";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "-1");
        }
Example #5
0
        public void TryCompare_SplitSeconds_One_Over_Expected_One_SplitSeconds()
        {
            _input2     = "2011/06/05 08:20:30:124 AM";
            _outputType = "Milliseconds";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.AreEqual("1", result);
        }
Example #6
0
        public void TryCompare_Years_One_Short_Expected_Zero_Years()
        {
            _input2     = "2012/06/05 08:20:30:122 AM";
            _outputType = "Years";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "0");
        }
Example #7
0
        public void TryCompare_Weeks_Negative_Expected_NegativeOne_Weeks()
        {
            _input2     = "2011/05/28 08:20:30:123 AM";
            _outputType = "Weeks";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.AreEqual("-2", result);
        }
Example #8
0
        public void TryCompare_SplitSeconds_Equal_Expected_Zero_SplitSeconds()
        {
            _input2     = "2011/06/05 08:20:30:123 AM";
            _outputType = "Milliseconds";
            var comparer       = DateTimeConverterFactory.CreateComparer();
            var dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "0");
        }
        public void TimeModifiers_Split_Secs_Zero_Expected_No_Change()
        {
            const string inputString  = "2025/02/15 11:21:51 AM";
            const string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            var dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            var dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Milliseconds", 0, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "2025/02/15 11:21:51 AM");
        }
        public void TimeModifiers_Seconds_Negative_Expected_Correct_Subtraction()
        {
            const string inputString  = "2025/02/15 11:21:51 AM";
            const string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            var dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            var dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Seconds", -2, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "2025/02/15 11:21:49 AM");
        }
        public void TimeModifiers_Days_Positive_Expected_Correct_Addition()
        {
            const string inputString  = "2025/06/15 11:21:51 AM";
            const string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            var dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            var dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Days", 30, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "2025/07/15 11:21:51 AM");
        }
        public void TryFormat_Converting_Date_To_ww_Expected_WeekReturnedInDoubleDigitFormat()
        {
            const string inputString  = "06-01-2013";
            const string formatString = "dd-mm-yyyy";

            var dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            var dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "ww", "", 0, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "02");
        }
        public void TimeModifiers_Blank_Positive_Expected_No_Change()
        {
            const string inputString  = "2012/02/15 11:21:51 AM";
            const string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            var dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            var dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "", 25, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out string result, out string error);
            Assert.IsTrue(result == "2012/02/15 11:21:51 AM");
        }
Example #14
0
        IDateTimeOperationTO ConvertToDateTimeTo(string evaledDateTime, string evaledInputFormat, string evaledOutputFormat, string timeModifierType, string tTimeModifierAmount)
        {
            var tmpTimeAmount = 0;

            if (!string.IsNullOrWhiteSpace(tTimeModifierAmount) && !int.TryParse(tTimeModifierAmount, out tmpTimeAmount))
            {
                throw new Exception(ErrorResource.TimeMustBeNumeric);
            }

            return(DateTimeConverterFactory.CreateDateTimeTO(evaledDateTime, evaledInputFormat, evaledOutputFormat, timeModifierType, tmpTimeAmount, Result));
        }
        public DateTimeIntellisenseProvider()
        {
            Optional = false;
            IntellisenseProviderType = IntellisenseProviderType.NonDefault;
            IDateTimeParser dateTimeParser = DateTimeConverterFactory.CreateParser();

            _intellisenseResults = dateTimeParser.DateTimeFormatParts.Select(p =>
            {
                IIntellisenseResult intellisenseResult = IntellisenseFactory.CreateDateTimeResult(IntellisenseFactory.CreateDateTimePart(p.Value, p.Description));
                return(intellisenseResult);
            }).OrderBy(p => p.Option.DisplayValue).ToList();
        }
Example #16
0
        public void TimeModifiers_Blank_Negative_Expected_No_Change()
        {
            string       result;
            string       error;
            const string inputString  = "2025/02/15 11:21:51 AM";
            const string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   dateTimeFormatter = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult    = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "", -25, "");

            dateTimeFormatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/02/15 11:21:51 AM");
        }
        public void TryCompare_Hours_One_Short_Expected_Zero_Hours()
        {
            string result;
            string error;

            _input2     = "2011/06/05 09:20:30:122 AM";
            _outputType = "Hours";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "0");
        }
        public void TryCompare_Minutes_Negative_Expected_NegativeOne_Minutes()
        {
            string result;
            string error;

            _input2     = "2011/06/05 08:19:30:123 AM";
            _outputType = "Minutes";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "-1");
        }
Example #19
0
        public void TryCompare_Minutes_Equal_Expected_One_Minutes()
        {
            string result;
            string error;

            Input2     = "2011/06/05 08:21:30:123 AM";
            OutputType = "Minutes";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, Input2, InputFormat, OutputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "1");
        }
        public void TimeModifiers_Split_Secs_Zero_Expected_No_Change()
        {
            string result;
            string error;
            string inputString  = "2025/02/15 11:21:51 AM";
            string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Split Secs", 0, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/02/15 11:21:51 AM");
        }
        public void TimeModifiers_Days_Negative_Expected_Correct_Subtraction()
        {
            string result;
            string error;
            string inputString  = "2025/06/15 11:21:51 AM";
            string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Days", -30, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/05/16 11:21:51 AM");
        }
        public void TimeModifiers_Seconds_Positive_Expected_Correct_Addition()
        {
            string result;
            string error;
            string inputString  = "2025/02/15 11:21:51 AM";
            string formatString = "yyyy/mm/dd 12h:min:ss am/pm";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "yyyy/mm/dd 12h:min:ss am/pm", "Seconds", 2, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2025/02/15 11:21:53 AM");
        }
Example #23
0
        public void TryCompare_Years_Negative_Years_Expected_NegativeOne_Years()
        {
            string result;
            string error;

            Input2     = "2010/06/05 08:20:30:124 AM";
            OutputType = "Years";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, Input2, InputFormat, OutputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "-1");
        }
        public void TryFormat_Converting_Date_To_Week_Expected_WeekofTheSpecifiedDataReturned()
        {
            string result;
            string error;
            string inputString  = "06-01-2013";
            string formatString = "dd-mm-yyyy";

            IDateTimeFormatter   formatter      = DateTimeConverterFactory.CreateFormatter();
            IDateTimeOperationTO dateTimeResult = DateTimeConverterFactory.CreateDateTimeTO(inputString, formatString, "w", "", 0, "");

            formatter.TryFormat(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "2");
        }
Example #25
0
        public void TryCompare_SplitSeconds_One_Over_Expected_One_SplitSeconds()
        {
            string result;
            string error;

            Input2     = "2011/06/05 08:20:30:124 AM";
            OutputType = "Split Secs";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, Input2, InputFormat, OutputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.AreEqual("1", result);
        }
Example #26
0
        public void TryCompare_SplitSeconds_One_Short_Expected_Zero_SplitSeconds()
        {
            string result;
            string error;

            Input2     = "2011/06/05 08:20:30:122 AM";
            OutputType = "Split Secs";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, Input2, InputFormat, OutputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "-1");
        }
        public void TryCompare_Seconds_One_Over_Expected_One_Seconds()
        {
            string result;
            string error;

            _input2     = "2011/06/05 08:20:31:124 AM";
            _outputType = "Seconds";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, _input2, InputFormat, _outputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "1");
        }
Example #28
0
        public void TryCompare_Weeks_One_Over_Expected_One_Weeks()
        {
            string result;
            string error;

            Input2     = "2011/06/12 08:20:30:124 AM";
            OutputType = "Weeks";
            IDateTimeComparer comparer       = DateTimeConverterFactory.CreateComparer();
            IDateTimeDiffTO   dateTimeResult = DateTimeConverterFactory.CreateDateTimeDiffTO(Input1, Input2, InputFormat, OutputType);

            comparer.TryCompare(dateTimeResult, out result, out error);
            Assert.IsTrue(result == "1");
        }
        void UpdateEnvironmentAndDebugOutput(IDSFDataObject dataObject, int update, ErrorResultTO allErrors)
        {
            var colItr = new WarewolfListIterator();

            var dtItr = CreateDataListEvaluateIterator(DateTime, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(dtItr);
            var ifItr = CreateDataListEvaluateIterator(string.IsNullOrEmpty(InputFormat) ? GlobalConstants.Dev2DotNetDefaultDateTimeFormat : InputFormat, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(ifItr);
            var ofItr = CreateDataListEvaluateIterator(string.IsNullOrEmpty(OutputFormat) ? GlobalConstants.Dev2DotNetDefaultDateTimeFormat : OutputFormat, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(ofItr);
            var tmaItr = CreateDataListEvaluateIterator(TimeModifierAmountDisplay, dataObject.Environment, update);

            colItr.AddVariableToIterateOn(tmaItr);

            if (!allErrors.HasErrors())
            {
                while (colItr.HasMoreData())
                {
                    var transObj = ConvertToDateTimeTo(colItr.FetchNextValue(dtItr),
                                                       colItr.FetchNextValue(ifItr),
                                                       colItr.FetchNextValue(ofItr),
                                                       TimeModifierType,
                                                       colItr.FetchNextValue(tmaItr)
                                                       );

                    var    format = DateTimeConverterFactory.CreateStandardFormatter();
                    string result;
                    string error;
                    if (format.TryFormat(transObj, out result, out error))
                    {
                        AddDefaultDebugInfo(dataObject, result);
                        AddDebugInfo(dataObject, update);
                        var expression = Result;
                        dataObject.Environment.Assign(expression, result, update);
                    }
                    else
                    {
                        allErrors.AddError(error);
                    }
                }
                if (dataObject.IsDebugMode() && !allErrors.HasErrors())
                {
                    var resDebug = new DebugEvalResult(Result, "", dataObject.Environment, update);
                    AddDebugOutputItem(resDebug);
                }
            }
        }
Example #30
0
        /// <summary>
        /// Used for converting the properties of this activity to a DateTimeTO object
        /// </summary>
        private IDateTimeOperationTO ConvertToDateTimeTo(string evaledDateTime, string evaledInputFormat, string evaledOutputFormat, string timeModifierType, string tTimeModifierAmount)
        {
            //2012.09.27: massimo.guerrera - Added for the new functionality for the time modification
            //Create a DateTimeTO using the DateTimeConverterFactory and send through the properties of this activity.DONE
            int tmpTimeAmount = 0;

            if (!string.IsNullOrWhiteSpace(tTimeModifierAmount))
            {
                if (!int.TryParse(tTimeModifierAmount, out tmpTimeAmount))
                {
                    throw new Exception("Add Time amount must be numeric");
                }
            }
            return(DateTimeConverterFactory.CreateDateTimeTO(evaledDateTime, evaledInputFormat, evaledOutputFormat, timeModifierType, tmpTimeAmount, Result));
        }