Windows.Globalization.Calendar.ChangeClock C# (CSharp) Method

ChangeClock() public method

public ChangeClock ( [ value ) : void
value [
return void
		public extern void ChangeClock([In] string value);
		public extern DateTime GetDateTime();

Usage Example

        /// <summary>
        /// This is the click handler for the 'combine' button.  The values of the TimePicker and DatePicker are combined into a single DateTimeOffset.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void combine_Click(object sender, RoutedEventArgs e)
        {
            DateTimeFormatter dateFormatter = new DateTimeFormatter("shortdate");
            DateTimeFormatter timeFormatter = new DateTimeFormatter("shorttime");

            // We use a calendar to determine daylight savings time transition days
            Calendar calendar = new Calendar();
            calendar.ChangeClock("24HourClock");

            // The value of the selected time in a TimePicker is stored as a TimeSpan, so it is possible to add it directly to the value of the selected date
            DateTimeOffset selectedDate = this.datePicker.Date;
            DateTimeOffset combinedValue = new DateTimeOffset(new DateTime(selectedDate.Year, selectedDate.Month, selectedDate.Day) + this.timePicker.Time);

            calendar.SetDateTime(combinedValue);

            // If the day does not have 24 hours, then the user has selected a day in which a Daylight Savings Time transition occurs.
            //    It is the app developer's responsibility for validating the combination of the date and time values.
            if (calendar.NumberOfHoursInThisPeriod != 24)
            {
                rootPage.NotifyUser("You selected a DST transition day", NotifyType.StatusMessage);
            }
            else
            {
                rootPage.NotifyUser("Combined value: " + dateFormatter.Format(combinedValue) + " " + timeFormatter.Format(combinedValue), NotifyType.StatusMessage);
            }
        }
All Usage Examples Of Windows.Globalization.Calendar::ChangeClock