public static double RoundTime(double timevalue, double unit, bool roundup) { long totalSeconds = (long)TimeSpan.FromDays(unit).TotalSeconds; if (totalSeconds > 0L) { timeHelper helper = new timeHelper(timevalue); if (totalSeconds < 60L) { helper.second = tround(helper.second, totalSeconds, roundup); return(helper.getTimeAsDouble()); } helper.second = 0; if (totalSeconds < 0xe10L) { totalSeconds /= 60L; helper.minute = tround(helper.minute, totalSeconds, roundup); return(helper.getTimeAsDouble()); } helper.minute = 0; if (totalSeconds < 0x15180L) { totalSeconds /= 0xe10L; helper.hour = tround(helper.hour, totalSeconds, roundup); return(helper.getTimeAsDouble()); } helper.hour = 0; if (totalSeconds < 0x28de80L) { totalSeconds /= 0x15180L; helper.day = tround(helper.day, totalSeconds, roundup); return(helper.getTimeAsDouble()); } helper.day = 1; if (totalSeconds < 0x1e13380L) { totalSeconds /= 0x28de80L; if (helper.month != 1) { helper.month = tround(helper.month, totalSeconds, roundup); } return(helper.getTimeAsDouble()); } helper.month = 1; totalSeconds /= 0x1e13380L; helper.year = tround(helper.year, totalSeconds, roundup); return(helper.getTimeAsDouble()); } double num2 = timevalue; double num3 = num2 - totalSeconds; double num4 = (num3 / unit) * unit; if (roundup && (num4 != num3)) { num4 += unit; } return(totalSeconds + num4); }
private void clockTimerTick(object sender, EventArgs e) { DateTime localDateTime = DateTime.Now; mLabelClock.Text = localDateTime.ToString(mCulture); //Calculate the different from start time to now time and show it in a label timeHelper helper = new timeHelper(); mLabelEinsatzdauer.Text = helper.getDiffTime(mStartTime); if (mBeginTypingNewMessage == false) { mTextFieldTime.Text = localDateTime.ToShortTimeString(); mTextFieldDate.Text = localDateTime.ToShortDateString(); mTextFieldTimer.Text = mLabelEinsatzdauer.Text; } }