public ActionResult TestUiDateTimeModelAsParameter(UiDateTimeModel modelOne, UiDateTimeModel modelTwo)
 {
     return Json(new {
         modelOneUtcDate = modelOne.DateTimeUtcValue.GetValueOrDefault().ToString("s"),
         modelTwoUtcDate = modelTwo.DateTimeUtcValue.GetValueOrDefault().ToString("s")
     });
 }
 public ActionResult TestUiDateTimeModelAsParameterWithGet(UiDateTimeModel modelOne, UiDateTimeModel modelTwo, string anotherProperty)
 {
     return Json(new {
         modelOneUtcDate = modelOne.DateTimeUtcValue.GetValueOrDefault().ToString("s"),
         modelTwoUtcDate = modelTwo.DateTimeUtcValue.GetValueOrDefault().ToString("s"),
         Other = anotherProperty
     },
     JsonRequestBehavior.AllowGet);
 }
 public void TestUiDateTimeModelWithLocalTimeOnlyPasses()
 {
     var timeZoneId = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").StandardName;
     var testUiDateTimeModel = new UiDateTimeModel(timeZoneId)
                                   {
                                       LocalTime = "9:00:00 PM"
                                   };
     Assert.AreEqual(DateTime.Parse("01/01/1753 9:00:00 PM"), testUiDateTimeModel.DateTimeLocalValue);
     Assert.AreEqual(DateTime.Parse("01/01/1753 9:00:00 PM").ToUniversalTime(timeZoneId), testUiDateTimeModel.DateTimeUtcValue);
 }
 public void TestUiDateTimeModelWithLocalDateAndLocalTimeSetPasses()
 {
     var timeZoneId = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").StandardName;
     var testUiDateTimeModel = new UiDateTimeModel(timeZoneId)
                                   {
                                       LocalDate = "02/28/2013",
                                       LocalTime = "11:00:00 PM"
                                   };
     Assert.AreEqual(DateTime.Parse("02/28/2013 11:00:00 PM"), testUiDateTimeModel.DateTimeLocalValue);
     Assert.AreEqual(DateTime.Parse("02/28/2013 11:00:00 PM").ToUniversalTime(timeZoneId), testUiDateTimeModel.DateTimeUtcValue);
 }
 public UiDateTimeRangeModel(string timeZoneName, DateTime?startDateUtc, DateTime?endDateUtc, bool isAllDay = false)
 {
     StartDateTime = new UiDateTimeModel(timeZoneName)
     {
         DateTimeUtcValue = startDateUtc, NoSetTime = isAllDay
     };
     EndDateTime = new UiDateTimeModel(timeZoneName)
     {
         DateTimeUtcValue = endDateUtc
     };
     TimeZoneName = timeZoneName;
 }
 public UiDateTimeRangeModel(string timeZoneName, DateTime?startDateUtc, DateTime?endDateUtc)
 {
     StartDateTime = new UiDateTimeModel(timeZoneName)
     {
         DateTimeUtcValue = startDateUtc
     };
     EndDateTime = new UiDateTimeModel(timeZoneName)
     {
         DateTimeUtcValue = endDateUtc
     };
     TimeZoneName = timeZoneName;
 }
 public UiDateTimeRangeModel(string timeZoneName, DateTime? startDateUtc, DateTime? endDateUtc, bool isAllDay = false)
 {
     StartDateTime = new UiDateTimeModel(timeZoneName) {DateTimeUtcValue = startDateUtc, NoSetTime = isAllDay};
     EndDateTime = new UiDateTimeModel(timeZoneName) {DateTimeUtcValue = endDateUtc};
     TimeZoneName = timeZoneName;
 }
 public UiDateTimeRangeModel(string timeZoneName, DateTime? startDateUtc, DateTime? endDateUtc)
 {
     StartDateTime = new UiDateTimeModel(timeZoneName) {DateTimeUtcValue = startDateUtc};
     EndDateTime = new UiDateTimeModel(timeZoneName) {DateTimeUtcValue = endDateUtc};
     TimeZoneName = timeZoneName;
 }
 /// <summary>
 /// Constructor for UiDateTimeModel that takes in the local time zone name to base the DateTime off of.
 /// </summary>
 /// <param name="timeZoneName">TimeZoneInfo name of the local time being represented.</param>
 public UiDateTimeRangeModel(string timeZoneName)
 {
     StartDateTime = new UiDateTimeModel(timeZoneName);
     EndDateTime = new UiDateTimeModel(timeZoneName);
     TimeZoneName = timeZoneName;
 }
 /// <summary>
 /// Constructor for UiDateTimeModel that takes in the local time zone name to base the DateTime off of.
 /// </summary>
 /// <param name="timeZoneName">TimeZoneInfo name of the local time being represented.</param>
 public UiDateTimeRangeModel(string timeZoneName)
 {
     StartDateTime = new UiDateTimeModel(timeZoneName);
     EndDateTime   = new UiDateTimeModel(timeZoneName);
     TimeZoneName  = timeZoneName;
 }
        public void TestUiDateTimeModelWithUtcDateTimeSetPasses()
        {
            var timeZoneId = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").StandardName;
            var dateTimeUtcValue = DateTime.Parse("02/28/2013 11:00:00 PM");

            var testUiDateTimeModel = new UiDateTimeModel(timeZoneId)
                                          {
                                              DateTimeUtcValue = dateTimeUtcValue
                                          };

            Assert.AreEqual(dateTimeUtcValue.ToLocalTime(timeZoneId), testUiDateTimeModel.DateTimeLocalValue);
            Assert.AreEqual(dateTimeUtcValue, testUiDateTimeModel.DateTimeUtcValue);
        }