Example #1
0
        private JULDATE_CURRENCY InternJulDatLngToJulDateCur(JULDATE_LONG vtypJulDateLng)
        {
            JULDATE_CURRENCY dtypJulDateCur = default(JULDATE_CURRENCY);

            dtypJulDateCur.jdCompl = Conversions.ToDecimal(vtypJulDateLng.jdDays + "," + vtypJulDateLng.jdTime);
            return(dtypJulDateCur);
        }
Example #2
0
        public decimal MakeJulTime(short nvintHour = 0, short nvintMinute = 0, short nvintSecond = 0, short nvintMilliSec = 0)
        {
            bool flag = true;

            if (flag == nvintHour < 0 || flag == nvintHour > 575)
            {
                Information.Err().Raise(50000, "UtilTime", "Der Stundenwert überschreitet den Gültigkeitsbereich.");
            }
            else if (flag == nvintMinute < 0 || flag == nvintMinute > 59)
            {
                Information.Err().Raise(50000, "UtilTime", "Der Minutenwert überschreitet den Gültigkeitsbereich.");
            }
            else if (flag == nvintSecond < 0 || flag == nvintSecond > 59)
            {
                Information.Err().Raise(50000, "UtilTime", "Der Sekundenwert überschreitet den Gültigkeitsbereich.");
            }
            else
            {
                if (flag != nvintMilliSec < 0 && flag != nvintMilliSec > 999)
                {
                    JULDATE_LONG dtypJulDateLng = default(JULDATE_LONG);
                    dtypJulDateLng.jdDays = 0;
                    dtypJulDateLng.jdTime = InternCalcJulTime(nvintHour, nvintMinute, nvintSecond, nvintMilliSec);
                    JULDATE_CURRENCY dtypJulDateCur = InternJulDatLngToJulDateCur(dtypJulDateLng);
                    return(dtypJulDateCur.jdCompl);
                }
                Information.Err().Raise(50000, "UtilTime", "Der Millisekundenwert überschreitet den Gültigkeitsbereich.");
            }
            decimal MakeJulTime = default(decimal);

            return(MakeJulTime);
        }
Example #3
0
        private decimal InternGetCurrencyDate(int vlngDays, int vlngTime)
        {
            if (vlngTime < 0)
            {
                Information.Err().Raise(50000, "UtilTime", "Zeit liegt außerhalb des Wertebereichs (<00:00:00:000).");
            }
            else if (vlngTime > 86399999)
            {
                Information.Err().Raise(50000, "UtilTime", "Zeit liegt außerhalb des Wertebereichs (>23:59:59:999).");
            }
            else
            {
                JULDATE_LONG dtypJulDateLng = default(JULDATE_LONG);
                dtypJulDateLng.jdTime = vlngTime;
                if (vlngDays >= 0)
                {
                    dtypJulDateLng.jdDays = vlngDays;
                    JULDATE_CURRENCY dtypJulDateCur = InternJulDatLngToJulDateCur(dtypJulDateLng);
                    return(dtypJulDateCur.jdCompl);
                }
                Information.Err().Raise(50000, "UtilTime", "Tagesdatum außerhalb des Wertebereichs.");
            }
            decimal InternGetCurrencyDate = default(decimal);

            return(InternGetCurrencyDate);
        }
Example #4
0
        public decimal MakeJulDate(short vintDay, short vintMonth, short vintYear, short nvintHour = 0, short nvintMinute = 0, short nvintSecond = 0, short nvintMilliSec = 0)
        {
            string dstrRefString = Support.Format(vintDay, "00\\.") + Support.Format(vintMonth, "00\\.") + Support.Format(vintYear, "0000\\ ") + Support.Format(nvintHour, "00\\:") + Support.Format(nvintMinute, "00\\:") + Support.Format(nvintSecond, "00");
            string dstrInpString = Conversions.ToString(DateTime.FromOADate(DateAndTime.DateSerial(vintYear, vintMonth, vintDay).ToOADate() + DateAndTime.TimeSerial(nvintHour, nvintMinute, nvintSecond).ToOADate()));

            if (Operators.CompareString(Support.Format(dstrInpString, "dd\\.mm\\.yyyy\\ hh\\:nn\\:ss"), dstrRefString, TextCompare: false) != 0)
            {
                Information.Err().Raise(50000, "UtilTime", "Der Datumswert ist ungültig.");
            }
            else
            {
                if (!(nvintMilliSec < 0 || nvintMilliSec > 999))
                {
                    JULDATE_LONG dtypJulDateLng = default(JULDATE_LONG);
                    dtypJulDateLng.jdDays = InternGetJulDays(vintDay, vintMonth, vintYear);
                    dtypJulDateLng.jdTime = InternCalcJulTime(nvintHour, nvintMinute, nvintSecond, nvintMilliSec);
                    JULDATE_CURRENCY dtypJulDateCur = InternJulDatLngToJulDateCur(dtypJulDateLng);
                    return(dtypJulDateCur.jdCompl);
                }
                Information.Err().Raise(50000, "UtilTime", "Millisekunden außerhalb des Gültigkeitsbereiches.");
            }
            decimal MakeJulDate = default(decimal);

            return(MakeJulDate);
        }
Example #5
0
        public DateTime JulDateToDate(decimal vcurJulDate)
        {
            if (!IsJulDate(vcurJulDate))
            {
                Information.Err().Raise(50000, "UtilTime", "Das Datum ist ungültig.");
            }
            else
            {
                JULDATE_LONG dtypJulDateLng = InternGetJulSplit(vcurJulDate);
                int          dlngTime       = dtypJulDateLng.jdTime;
                DateTime     ddatTemp       = DateTime.FromOADate(InternGetGregDate(dtypJulDateLng.jdDays).ToOADate() + DateAndTime.TimeSerial(InternTimeToHours(dlngTime), InternTimeToMinutes(dlngTime), InternTimeToSeconds(dlngTime)).ToOADate());
                DateTime     t = ddatTemp;
                if (DateTime.Compare(t, new DateTime(499230432000000000L)) < 0)
                {
                    Information.Err().Raise(50000, "UtilTime", "Das Ergebnis liefert ein Datum, das vor dem Gültigkeitsbereich liegt.");
                }
                else
                {
                    if (DateTime.Compare(t, new DateTime(693937151990000000L)) <= 0)
                    {
                        return(ddatTemp);
                    }
                    Information.Err().Raise(50000, "UtilTime", "Das Ergebnis liefert ein Datum, das nach dem Gültigkeitsbereich liegt.");
                }
            }
            DateTime JulDateToDate = default(DateTime);

            return(JulDateToDate);
        }
Example #6
0
 private JULDATE_LONG InternJulDatCurToJulDateLng(JULDATE_CURRENCY vtypJulDateCur)
 {
     string[] dastrValues = vtypJulDateCur.jdCompl.ToString().Split(',');
     checked
     {
         JULDATE_LONG dtypJulDateLng = default(JULDATE_LONG);
         dtypJulDateLng.jdDays = (int)Conversions.ToLong(dastrValues[0]);
         dtypJulDateLng.jdTime = (int)Conversions.ToLong(dastrValues[1]);
         return(dtypJulDateLng);
     }
 }
Example #7
0
        public object JulDateToAcadDate(decimal vcurJulDate)
        {
            if (!IsJulDate(vcurJulDate))
            {
                Information.Err().Raise(50000, "UtilTime", "Das Datum ist ungültig.");
                object JulDateToAcadDate = default(object);
                return(JulDateToAcadDate);
            }
            JULDATE_LONG dtypJulDateLng = InternGetJulSplit(vcurJulDate);

            return(decimal.Add(new decimal(dtypJulDateLng.jdDays), decimal.Divide(new decimal(dtypJulDateLng.jdTime), new decimal(100000000L))));
        }
Example #8
0
        public object JulDateGetIntervall(Enums.TiJulDateIntervall vnumIntervall, decimal vcurJulDate1, decimal vcurJulDate2)
        {
            if (!IsJulDate(vcurJulDate1))
            {
                Information.Err().Raise(50000, "UtilTime", "Das erste Datum ist ungültig.");
            }
            else
            {
                if (IsJulDate(vcurJulDate2))
                {
                    JULDATE_LONG dtypJulDateLng1 = InternGetJulSplit(vcurJulDate1);
                    JULDATE_LONG dtypJulDateLng2 = InternGetJulSplit(vcurJulDate2);
                    int          dlngTime1       = dtypJulDateLng1.jdTime;
                    int          dlngTime2       = dtypJulDateLng2.jdTime;
                    object       dvarVarDat1     = default(object);
                    object       dvarVarDat2     = default(object);
                    switch (vnumIntervall)
                    {
                    case Enums.TiJulDateIntervall.tiDays:
                        dvarVarDat1 = new decimal(dtypJulDateLng1.jdDays);
                        dvarVarDat2 = new decimal(dtypJulDateLng2.jdDays);
                        break;

                    case Enums.TiJulDateIntervall.tiHours:
                        dvarVarDat1 = decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng1.jdDays), new decimal(24L)), new decimal(InternTimeToHours(dlngTime1)));
                        dvarVarDat2 = decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng2.jdDays), new decimal(24L)), new decimal(InternTimeToHours(dlngTime2)));
                        break;

                    case Enums.TiJulDateIntervall.tiMinutes:
                        dvarVarDat1 = decimal.Add(decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng1.jdDays), new decimal(1440L)), decimal.Multiply(new decimal(InternTimeToHours(dlngTime1)), new decimal(60L))), new decimal(InternTimeToMinutes(dlngTime1)));
                        dvarVarDat2 = decimal.Add(decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng2.jdDays), new decimal(1440L)), decimal.Multiply(new decimal(InternTimeToHours(dlngTime2)), new decimal(60L))), new decimal(InternTimeToMinutes(dlngTime2)));
                        break;

                    case Enums.TiJulDateIntervall.tiSeconds:
                        dvarVarDat1 = decimal.Add(decimal.Add(decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng1.jdDays), new decimal(86400L)), decimal.Multiply(new decimal(InternTimeToHours(dlngTime1)), new decimal(3600L))), decimal.Multiply(new decimal(InternTimeToMinutes(dlngTime1)), new decimal(60L))), new decimal(InternTimeToSeconds(dlngTime1)));
                        dvarVarDat2 = decimal.Add(decimal.Add(decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng2.jdDays), new decimal(86400L)), decimal.Multiply(new decimal(InternTimeToHours(dlngTime2)), new decimal(3600L))), decimal.Multiply(new decimal(InternTimeToMinutes(dlngTime2)), new decimal(60L))), new decimal(InternTimeToSeconds(dlngTime2)));
                        break;

                    case Enums.TiJulDateIntervall.tiMilliSecs:
                        dvarVarDat1 = decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng1.jdDays), new decimal(86400000L)), decimal.Multiply(new decimal(InternTimeToHours(dlngTime1)), new decimal(3600000L))), decimal.Multiply(new decimal(InternTimeToMinutes(dlngTime1)), new decimal(60000L))), decimal.Multiply(new decimal(InternTimeToSeconds(dlngTime1)), new decimal(1000L))), new decimal(InternTimeToMilliSecs(dlngTime1)));
                        dvarVarDat2 = decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Multiply(new decimal(dtypJulDateLng2.jdDays), new decimal(86400000L)), decimal.Multiply(new decimal(InternTimeToHours(dlngTime2)), new decimal(3600000L))), decimal.Multiply(new decimal(InternTimeToMinutes(dlngTime2)), new decimal(60000L))), decimal.Multiply(new decimal(InternTimeToSeconds(dlngTime2)), new decimal(1000L))), new decimal(InternTimeToMilliSecs(dlngTime2)));
                        break;
                    }
                    return(Conversions.ToDecimal(Operators.SubtractObject(dvarVarDat2, dvarVarDat1)));
                }
                Information.Err().Raise(50000, "UtilTime", "Das zweite Datum ist ungültig.");
            }
            object JulDateGetIntervall = default(object);

            return(JulDateGetIntervall);
        }
Example #9
0
        public bool IsJulDate(decimal vcurJulDate)
        {
            JULDATE_LONG dtypJulDateLng = InternGetJulSplit(vcurJulDate);
            bool         dblnOk         = true;
            int          jdTime         = dtypJulDateLng.jdTime;

            if (jdTime < 0)
            {
                dblnOk = false;
            }
            else if (jdTime > 86399999)
            {
                dblnOk = false;
            }
            else if (dtypJulDateLng.jdDays < 1)
            {
                dblnOk = false;
            }
            return(dblnOk);
        }
Example #10
0
        public decimal JulDateAddIntervall(Enums.TiJulDateIntervall vnumIntervall, decimal vcurJulDate, int vlngValue)
        {
            if (!IsJulDate(vcurJulDate))
            {
                Information.Err().Raise(50000, "UtilTime", "Das Datum ist ungültig.");
                goto IL_025a;
            }
            int dlngDays2 = default(int);
            int dlngTime2 = default(int);

            switch (vnumIntervall)
            {
            case Enums.TiJulDateIntervall.tiDays:
                dlngDays2 = Math.Abs(vlngValue);
                dlngTime2 = 0;
                break;

            case Enums.TiJulDateIntervall.tiHours:
                dlngDays2 = Math.Abs(vlngValue) / 24;
                dlngTime2 = Convert.ToInt32(decimal.Subtract(decimal.Multiply(new decimal(Math.Abs(vlngValue)), new decimal(3600000L)), decimal.Multiply(new decimal(dlngDays2), new decimal(86400000L))));
                break;

            case Enums.TiJulDateIntervall.tiMinutes:
                dlngDays2 = Math.Abs(vlngValue) / 1440;
                dlngTime2 = Convert.ToInt32(decimal.Subtract(decimal.Multiply(new decimal(Math.Abs(vlngValue)), new decimal(60000L)), decimal.Multiply(new decimal(dlngDays2), new decimal(86400000L))));
                break;

            case Enums.TiJulDateIntervall.tiSeconds:
                dlngDays2 = Math.Abs(vlngValue) / 86400;
                dlngTime2 = Convert.ToInt32(decimal.Subtract(decimal.Multiply(new decimal(Math.Abs(vlngValue)), new decimal(1000L)), decimal.Multiply(new decimal(dlngDays2), new decimal(86400000L))));
                break;

            case Enums.TiJulDateIntervall.tiMilliSecs:
                dlngDays2 = Math.Abs(vlngValue) / 86400000;
                dlngTime2 = Convert.ToInt32(decimal.Subtract(new decimal(Math.Abs(vlngValue)), decimal.Multiply(new decimal(dlngDays2), new decimal(86400000L))));
                break;
            }
            JULDATE_LONG dtypJulDateLng      = InternGetJulSplit(vcurJulDate);
            decimal      JulDateAddIntervall = default(decimal);

            checked
            {
                if (vlngValue >= 0)
                {
                    dlngDays2 = dtypJulDateLng.jdDays + dlngDays2;
                    dlngTime2 = dtypJulDateLng.jdTime + dlngTime2;
                    InternCheckMaxTime(ref dlngDays2, ref dlngTime2);
                }
                else
                {
                    dlngDays2 = dtypJulDateLng.jdDays - dlngDays2;
                    if (dlngDays2 < 1)
                    {
                        Information.Err().Raise(50000, "UtilTime", "Subtraktion unterschreitet den Wertebereich.");
                        goto IL_025a;
                    }
                    dlngTime2 = dtypJulDateLng.jdTime - dlngTime2;
                    InternCheckMinTime(ref dlngDays2, ref dlngTime2);
                }
                try
                {
                    JulDateAddIntervall = InternGetCurrencyDate(dlngDays2, dlngTime2);
                    return(JulDateAddIntervall);
                }
                catch (Exception ex2)
                {
                    ProjectData.SetProjectError(ex2);
                    Exception ex         = ex2;
                    string    dstrErrMsg = ExceptionHelper.GetExceptionMessage(ex);
                    Information.Err().Raise(50000, "UtilTime", "Fehler beim Addieren/Subtrahieren des Intervalls.\n" + dstrErrMsg);
                    ProjectData.ClearProjectError();
                    return(JulDateAddIntervall);
                }
            }
IL_025a:
            JulDateAddIntervall = default;
            return(JulDateAddIntervall);
        }
Example #11
0
        public decimal JulDateCalc(Enums.TiJulDateCalcModus vnumCalcModus, decimal vcurJulDate1, decimal vcurJulDate2)
        {
            JULDATE_LONG dtypJulDateLng1 = InternGetJulSplit(vcurJulDate1);
            JULDATE_LONG dtypJulDateLng2 = InternGetJulSplit(vcurJulDate2);
            int          dlngDays2       = dtypJulDateLng1.jdDays;
            int          dlngDays3       = dtypJulDateLng2.jdDays;
            int          dlngTime2       = dtypJulDateLng1.jdTime;
            int          dlngTime3       = dtypJulDateLng2.jdTime;

            Enums.TiJulDateType tiJulDateType = InternJulDateType(dlngDays2, dlngTime2);
            int dlngDays = default(int);
            int dlngTime = default(int);

            checked
            {
                if (tiJulDateType != 0)
                {
                    if (tiJulDateType == Enums.TiJulDateType.tiJulTimeOnly)
                    {
                        InternCheckTime(ref dlngDays2, ref dlngTime2);
                    }
                    Enums.TiJulDateType tiJulDateType2 = InternJulDateType(dlngDays3, dlngTime3);
                    if (tiJulDateType2 != 0)
                    {
                        if (tiJulDateType2 == Enums.TiJulDateType.tiJulTimeOnly)
                        {
                            InternCheckTime(ref dlngDays3, ref dlngTime3);
                        }
                        if (vnumCalcModus != Enums.TiJulDateCalcModus.tiAddDates)
                        {
                            if (vnumCalcModus == Enums.TiJulDateCalcModus.tiSubDates)
                            {
                                dlngDays = dlngDays2 - dlngDays3;
                                dlngTime = dlngTime2 - dlngTime3;
                                InternCheckMinTime(ref dlngDays, ref dlngTime);
                                Enums.TiJulDateType tiJulDateType3 = InternJulDateType(dlngDays, dlngTime);
                                if (tiJulDateType3 != Enums.TiJulDateType.tiJulDateTime)
                                {
                                    if (tiJulDateType3 != Enums.TiJulDateType.tiJulTimeOnly || dlngDays >= 0)
                                    {
                                        goto IL_018d;
                                    }
                                    Information.Err().Raise(50000, "UtilTime", "Subtraktion unterschreitet den Wertebereich.");
                                }
                                else
                                {
                                    if (dlngDays >= 1)
                                    {
                                        goto IL_018d;
                                    }
                                    Information.Err().Raise(50000, "UtilTime", "Subtraktion unterschreitet den Wertebereich.");
                                }
                                goto IL_01d6;
                            }
                        }
                        else
                        {
                            dlngDays = dlngDays2 + dlngDays3;
                            dlngTime = dlngTime2 + dlngTime3;
                            InternCheckMaxTime(ref dlngDays, ref dlngTime);
                        }
                        goto IL_018d;
                    }
                    Information.Err().Raise(50000, "UtilTime", "Das zweite Datum ist ungültig.");
                }
                else
                {
                    Information.Err().Raise(50000, "UtilTime", "Das erste Datum ist ungültig.");
                }
                goto IL_01d6;
            }
IL_01d6:
            decimal JulDateCalc = default(decimal);

            return(JulDateCalc);

IL_018d:
            try
            {
                JulDateCalc = InternGetCurrencyDate(dlngDays, dlngTime);
                return(JulDateCalc);
            }
            catch (Exception ex2)
            {
                ProjectData.SetProjectError(ex2);
                Exception ex         = ex2;
                string    dstrErrMsg = ExceptionHelper.GetExceptionMessage(ex);
                Information.Err().Raise(50000, "UtilTime", "Fehler beim Addieren/Subtrahieren der Datumsangaben.\n" + dstrErrMsg);
                ProjectData.ClearProjectError();
                JulDateCalc = default(decimal);
                return(JulDateCalc);
            }
        }
Example #12
0
        public Enums.TiJulDateType JulDateType(decimal vcurJulDate)
        {
            JULDATE_LONG dtypJulDateLng = InternGetJulSplit(vcurJulDate);

            return(InternJulDateType(dtypJulDateLng.jdDays, dtypJulDateLng.jdTime));
        }