public void AddSeconds_Arround3Days_AreEqual() { var act = TestStruct.AddSeconds(3 * 24 * 60 * 64); var exp = new Date(1970, 02, 17); Assert.AreEqual(exp, act); }
void check() { startTime = Date; endTime = Date.AddSeconds(80); //endTime.AddSeconds(10); TimeSpan timecal = endTime - startTime; timesec = timecal.Seconds; }
public IList <DateTime> ToList() { if (Rounding != DateListIncrementRounding.None) { RoundDate(); } var targetCount = Math.Abs(Count); var dateList = new List <DateTime>(); do { var step = StepSize * dateList.Count; switch (Increment) { case DateListIncrement.Second: dateList.Add(Date.AddSeconds(step)); break; case DateListIncrement.Minute: dateList.Add(Date.AddMinutes(step)); break; case DateListIncrement.Hour: dateList.Add(Date.AddHours(step)); break; case DateListIncrement.Day: dateList.Add(Date.AddDays(step)); break; case DateListIncrement.Month: dateList.Add(Date.AddMonths(step)); break; case DateListIncrement.Year: dateList.Add(Date.AddYears(step)); break; default: throw new ArgumentOutOfRangeException(); } } while (dateList.Count < targetCount); return(dateList); }
/// <summary> /// Get value for the seconds at specified step. /// </summary> /// <param name="steps">Step.</param> /// <returns>Formatted seconds.</returns> protected string SecondsValue(int steps) { return(Date.AddSeconds(steps * SecondsStep).ToString(SecondsFormat, Culture)); }
public static DateTime ToDateTime(this string StrDateTime) { DateTime Date = new DateTime(); if (!string.IsNullOrWhiteSpace(StrDateTime)) { StrDateTime = StrDateTime.Trim(); string StrDate = ""; string StrTime = ""; string AMPM = ""; bool IsPM = false; if (StrDateTime.IndexOf(" ") > 8 && StrDateTime.Split(' ').Count() == 2) { StrDate = StrDateTime.Split(' ')[0]; StrTime = StrDateTime.Split(' ')[1]; } else if (StrDateTime.IndexOf(" ") > 8 && StrDateTime.Split(' ').Count() == 3) { StrDate = StrDateTime.Split(' ')[0]; StrTime = StrDateTime.Split(' ')[1]; AMPM = StrDateTime.Split(' ')[2]; IsPM = AMPM.ToLower() == "pm"; } else { StrDate = StrDateTime; } #region Date var Datevalues = StrDate.Trim().Split('/'); if (Datevalues.Length == 3) { int Day = 0; int Month = 0; int Year = 0; if (int.TryParse(Datevalues[0], out Month) && Month > 0 && Month < 13 && int.TryParse(Datevalues[1], out Day) && Day > 0 && Day < 32 && int.TryParse(Datevalues[2], out Year) && Year > 1980) { Date = new DateTime(Year, Month, Day); } } #endregion #region Time if (Date != new DateTime() && !string.IsNullOrWhiteSpace(StrTime)) { //if(StrTime.IndexOf(" ") > 2) //{ // StrTime = StrTime.Split(' ')[0]; // IsPM = StrTime.Split(' ')[1].ToLower() == "pm"; //} var Timevalues = StrTime.Trim().Split(':'); #region AddTime if (Timevalues.Length > 1 && Timevalues.Length < 4) { int Hour = 0; int Munite = 0; int Second = 0; if (int.TryParse(Timevalues[0], out Hour) && Hour > -1 && Hour < 24) { if (IsPM && Hour < 13) { Hour += 12; } Date = Date.AddHours(Hour); } if (int.TryParse(Timevalues[1], out Munite) && Munite > -1 && Munite < 60) { Date = Date.AddMinutes(Munite); } if (Timevalues.Length > 2 && int.TryParse(Timevalues[2], out Second) && Second > -1 && Second < 60) { Date = Date.AddSeconds(Second); } } #endregion } #endregion } return(Date); }
public DateTimeEntity AddSecconds(int sec) { Date = Date.AddSeconds(sec); return(this); }
// Μέθοδο που προσθέτει δευτερόλεπτά στην ημερομηνία public void AddSeconds(double seconds) { Date = Date.AddSeconds(seconds); }