Beispiel #1
0
        string[] CreateDateTimeFeatures(DateTime dateTime)
        {
            var year       = dateTime.Year;
            var month      = dateTime.Month;
            var dayOfMonth = dateTime.Day;
            var dayOfWeek  = (int)dateTime.DayOfWeek;
            var hours      = dateTime.TimeOfDay.Hours;
            var totalDays  = Math.Round(dateTime.Subtract(m_startDate).TotalDays, 1);
            var totalhours = Math.Round(dateTime.Subtract(m_startDate).TotalHours, 1);

            var dfi        = DateTimeFormatInfo.CurrentInfo;
            var cal        = dfi.Calendar;
            var weekOfYear = cal.GetWeekOfYear(dateTime, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);

            var timeValues = new string[]
            {
                FloatingPointConversion.ToString(year),
                FloatingPointConversion.ToString(month),
                FloatingPointConversion.ToString(weekOfYear),
                FloatingPointConversion.ToString(dayOfMonth),
                FloatingPointConversion.ToString(dayOfWeek),
                FloatingPointConversion.ToString(hours),
                FloatingPointConversion.ToString(totalDays),
                FloatingPointConversion.ToString(totalhours),
            };

            return(timeValues);
        }
Beispiel #2
0
        public void FloatingPointConversion_ToString()
        {
            var value  = 1.2354236;
            var actual = FloatingPointConversion.ToString(value);

            Assert.AreEqual("1.2354236", actual);
        }
Beispiel #3
0
        public void F64MatrixExtensions_ToStringMatrix()
        {
            var matrix = new F64Matrix(InputData, 2, 3);
            var actual = matrix.ToStringMatrix();

            var expected = new StringMatrix(InputData.Select(v => FloatingPointConversion.ToString(v)).ToArray(), 2, 3);

            Assert.AreEqual(expected, actual);
        }
 /// <summary>
 /// Converts an array of doubles to an array of strings
 /// </summary>
 /// <param name="v"></param>
 /// <returns></returns>
 public static string[] AsString(this double[] v)
 {
     return(v.Select(s => FloatingPointConversion.ToString(s)).ToArray());
 }