public static void SetTime(DateTime date, DateTime time) { if (date != null && time != null) { date.SetHours(time.GetHours()); date.SetMinutes(time.GetMinutes()); date.SetSeconds(time.GetSeconds()); date.SetMilliseconds(time.GetMilliseconds()); } }
public static DateTime AddTimeToDate(DateTime date, string time) { if (date == null) { date = DateTime.Now; } if (time != null) { DateTime dateWithTime = DateTime.Parse("01 Jan 2000 " + time.Replace(".", ":").Replace("-", ":").Replace(",", ":")); DateTime newDate = new DateTime(date.GetTime()); if (!Number.IsNaN((Number)((object)dateWithTime))) { newDate.SetHours(dateWithTime.GetHours()); newDate.SetMinutes(dateWithTime.GetMinutes()); newDate.SetSeconds(dateWithTime.GetSeconds()); newDate.SetMilliseconds(dateWithTime.GetMilliseconds()); return(newDate); } return(null); } return(date); }