Format() 공개 메소드

public Format ( [ value ) : string
value [
리턴 string
예제 #1
0
        private async Task CalendarCall(object sender, RoutedEventArgs e)
        {
            AppointmentStore calendar = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly);

            options1.FetchProperties.Add(AppointmentProperties.Subject);
            options1.FetchProperties.Add(AppointmentProperties.Details);
            options1.FetchProperties.Add(AppointmentProperties.DetailsKind);

            int DaysToCheckForAppointments;

            objTextBox.Text = questionForDaysAppointments;
            await  Speak(sender, e);

            Debug.WriteLine("endiamesooooooooooooooooooooooooooo \n");
            await Task.Delay(TimeSpan.FromSeconds(3));

            await SpeakToComputer(sender, e);

            Debug.WriteLine("I said " + objTextBox.Text);
            if (!(Int32.TryParse(objTextBox.Text.Split(' ').First(), out DaysToCheckForAppointments)))
            {
                Debug.WriteLine(DaysToCheckForAppointments);
                DaysToCheckForAppointments = 1;
            }

            var iteratingAppointments = await calendar.FindAppointmentsAsync(DateTimeOffset.Now, TimeSpan.FromDays(DaysToCheckForAppointments), options1);

            if (!iteratingAppointments.Any())
            {
                objTextBox.Text = "Δεν υπάρχουν ραντεβού για τις επόμενες " + DaysToCheckForAppointments + " μέρες.";

                return;
            }
            foreach (var i in iteratingAppointments)
            {
                var eventName     = i.Subject;
                var eventDay      = i.StartTime.DayOfWeek;
                var eventPlace    = i.Location;
                var timeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("hour minute");
                var eventTime     = timeFormatter.Format(i.StartTime.DateTime);

                objTextBox.Text = "Έχεις " + eventName + " στις " + eventDay + " την " + eventPlace + " την " + eventTime;
                if (i == iteratingAppointments.ElementAt(iteratingAppointments.Count() - 1))
                {
                    return;
                }
                stream = await synth.SynthesizeTextToStreamAsync(objTextBox.Text);


                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
                await Task.Delay(TimeSpan.FromSeconds(5));
            }

            return;
        }
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.Calendar class to enumerate through a calendar and
            // perform calendar math
            StringBuilder results = new StringBuilder();

            results.AppendLine("The number of years in each era of the Japanese era calendar is not regular. It is determined by the length of the given imperial era:\n");

            // Create Japanese calendar.
            Calendar calendar = new Calendar(new[] { "en-US" }, CalendarIdentifiers.Japanese, ClockIdentifiers.TwentyFourHour);

            // Enumerate all supported years in all supported Japanese eras.
            for (calendar.Era = calendar.FirstEra; true; calendar.AddYears(1))
            {
                // Process current era.
                results.AppendLine("Era " + calendar.EraAsString() + " contains " + calendar.NumberOfYearsInThisEra + " year(s)");

                // Enumerate all years in this era.
                for (calendar.Year = calendar.FirstYearInThisEra; true; calendar.AddYears(1))
                {
                    // Begin sample processing of current year.

                    // Move to first day of year. Change of month can affect day so order of assignments is important.
                    calendar.Month = calendar.FirstMonthInThisYear;
                    calendar.Day = calendar.FirstDayInThisMonth;

                    // Set time to midnight (local).
                    calendar.Period = calendar.FirstPeriodInThisDay;    // All days have 1 or 2 periods depending on clock type
                    calendar.Hour = calendar.FirstHourInThisPeriod;     // Hours start from 12 or 0 depending on clock type
                    calendar.Minute = 0;
                    calendar.Second = 0;
                    calendar.Nanosecond = 0;

                    if (calendar.Year % 1000 == 0)
                    {
                        results.AppendLine();
                    }
                    else if (calendar.Year % 10 == 0)
                    {
                        results.Append(".");
                    }

                    // End sample processing of current year.

                    // Break after processing last year.
                    if (calendar.Year == calendar.LastYearInThisEra)
                    {
                        break;
                    }
                }
                results.AppendLine();

                // Break after processing last era.
                if (calendar.Era == calendar.LastEra)
                {
                    break;
                }
            }

            // This section shows enumeration through the hours in a day to demonstrate that the number of time units in a given period (hours in a day, minutes in an hour, etc.)
            // should not be regarded as fixed. With Daylight Saving Time and other local calendar adjustments, a given day may have not have 24 hours, and
            // a given hour may not have 60 minutes, etc.
            results.AppendLine("\nThe number of hours in a day is not invariable. The US calendar transitions from DST to standard time on 4 November 2012:\n");

            // Create a DateTimeFormatter to display dates
            DateTimeFormatter displayDate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longdate");

            // Create a gregorian calendar for the US with 12-hour clock format
            Calendar currentCal = new Windows.Globalization.Calendar(new string[] { "en-US" }, CalendarIdentifiers.Gregorian, ClockIdentifiers.TwentyFourHour, "america/los_angeles");

            // Set the calendar to a the date of the Daylight Saving Time-to-Standard Time transition for the US in 2012.
            // DST ends in the US at 02:00 on 4 November 2012
            DateTime dstDate = new DateTime(2012, 11, 4);  
            currentCal.SetDateTime(dstDate);

            // Set the current calendar to one day before DST change. Create a second calendar for comparision and set it to one day after DST change.
            Calendar endDate = currentCal.Clone();
            currentCal.AddDays(-1);
            endDate.AddDays(1);

            // Enumerate the day before, the day of, and the day after the 2012 DST-to-Standard time transition
            while (currentCal.Day <= endDate.Day)
            {
                // Process current day.
                DateTimeOffset date = currentCal.GetDateTime();
                results.AppendFormat("{0} contains {1} hour(s)\n", displayDate.Format(date), currentCal.NumberOfHoursInThisPeriod);

                // Enumerate all hours in this day.
                // Create a calendar to represent the following day.
                Calendar nextDay = currentCal.Clone();
                nextDay.AddDays(1);
                for (currentCal.Hour = currentCal.FirstHourInThisPeriod; true; currentCal.AddHours(1)) 
                {
                    // Display the hour for each hour in the day.             
                    results.AppendFormat("{0} ", currentCal.HourAsPaddedString(2));

                    // Break upon reaching the next period (i.e. the first period in the following day).
                    if (currentCal.Day == nextDay.Day && currentCal.Period == nextDay.Period) 
                    {
                        break;
                    }
                }

                results.AppendLine();
            }

            // Display results
            OutputTextBlock.Text = results.ToString();
        }
예제 #3
0
        /// <summary>
        /// Creates a DateTimeFormatter object that is initialized with year, month, day, and day of week formats.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="yearFormat">The desired year format to include in the template.</param>
        /// <param name="monthFormat">The desired month format to include in the template.</param>
        /// <param name="dayFormat">The desired day format to include in the template.</param>
        /// <param name="dayOfWeekFormat">The desired day of week format to include in the template.</param>
        /// <returns></returns>
        public static string Format(this DateTime dt, YearFormat yearFormat, MonthFormat monthFormat, DayFormat dayFormat, DayOfWeekFormat dayOfWeekFormat)
        {
            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(yearFormat, monthFormat, dayFormat, dayOfWeekFormat);

            return(formatter.Format(dt));
        }
예제 #4
0
        /// <summary>
        /// Creates a DateTimeFormatter object that is initialized with hour, minute, and second formats.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="hourFormat">The desired hour format to include in the template.</param>
        /// <param name="minuteFormat">The desired minute format to include in the template.</param>
        /// <param name="secondFormat">The desired second format to include in the template.</param>
        /// <returns></returns>
        public static string Format(this DateTime dt, HourFormat hourFormat, MinuteFormat minuteFormat, SecondFormat secondFormat)
        {
            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(hourFormat, minuteFormat, secondFormat);

            return(formatter.Format(dt));
        }
예제 #5
0
        public static string Format(this DateTime dt, string formatTemplate, IEnumerable <string> languages)
        {
            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(formatTemplate, languages);

            return(formatter.Format(dt));
        }
예제 #6
0
        /// <summary>
        /// Creates a DateTimeFormatter object that is initialized by a format template string.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="formatTemplate">A format template string that specifies the requested components. The order of the components is irrelevant.  This can also be a format pattern.</param>
        /// <returns></returns>
        public static string Format(this DateTime dt, string formatTemplate)
        {
            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(formatTemplate);

            return(formatter.Format(dt));
        }
예제 #7
0
        public static string Format(this DateTime dt, YearFormat yearFormat, MonthFormat monthFormat, DayFormat dayFormat, DayOfWeekFormat dayOfWeekFormat, HourFormat hourFormat, MinuteFormat minuteFormat, SecondFormat secondFormat, IEnumerable <string> languages, string geographicRegion, string calendar, string clock)
        {
            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(yearFormat, monthFormat, dayFormat, dayOfWeekFormat, hourFormat, minuteFormat, secondFormat, languages, geographicRegion, calendar, clock);

            return(formatter.Format(dt));
        }
예제 #8
0
        public static string Format(this DateTime dt, string formatTemplate, IEnumerable <string> languages, string geographicRegion, string calendar, string clock)
        {
            var formatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(formatTemplate, languages, geographicRegion, calendar, clock);

            return(formatter.Format(dt));
        }
예제 #9
0
        /// <summary>
        /// This is the click handler for the 'Default' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Display_Click(object sender, RoutedEventArgs e)
        {
            // This scenario uses the Windows.Globalization.Calendar class to enumerate through a calendar and
            // perform calendar math
            StringBuilder results = new StringBuilder();

            results.AppendLine("The number of years in each era of the Japanese era calendar is not regular. It is determined by the length of the given imperial era:\n");

            // Create Japanese calendar.
            Calendar calendar = new Calendar(new[] { "en-US" }, CalendarIdentifiers.Japanese, ClockIdentifiers.TwentyFourHour);

            // Enumerate all supported years in all supported Japanese eras.
            for (calendar.Era = calendar.FirstEra; true; calendar.AddYears(1))
            {
                // Process current era.
                results.AppendLine("Era " + calendar.EraAsString() + " contains " + calendar.NumberOfYearsInThisEra + " year(s)");

                // Enumerate all years in this era.
                for (calendar.Year = calendar.FirstYearInThisEra; true; calendar.AddYears(1))
                {
                    // Begin sample processing of current year.

                    // Move to first day of year. Change of month can affect day so order of assignments is important.
                    calendar.Month = calendar.FirstMonthInThisYear;
                    calendar.Day   = calendar.FirstDayInThisMonth;

                    // Set time to midnight (local).
                    calendar.Period     = calendar.FirstPeriodInThisDay;  // All days have 1 or 2 periods depending on clock type
                    calendar.Hour       = calendar.FirstHourInThisPeriod; // Hours start from 12 or 0 depending on clock type
                    calendar.Minute     = 0;
                    calendar.Second     = 0;
                    calendar.Nanosecond = 0;

                    if (calendar.Year % 1000 == 0)
                    {
                        results.AppendLine();
                    }
                    else if (calendar.Year % 10 == 0)
                    {
                        results.Append(".");
                    }

                    // End sample processing of current year.

                    // Break after processing last year.
                    if (calendar.Year == calendar.LastYearInThisEra)
                    {
                        break;
                    }
                }
                results.AppendLine();

                // Break after processing last era.
                if (calendar.Era == calendar.LastEra)
                {
                    break;
                }
            }

            // This section shows enumeration through the hours in a day to demonstrate that the number of time units in a given period (hours in a day, minutes in an hour, etc.)
            // should not be regarded as fixed. With Daylight Saving Time and other local calendar adjustments, a given day may have not have 24 hours, and
            // a given hour may not have 60 minutes, etc.
            results.AppendLine("\nThe number of hours in a day is not invariable. The US calendar transitions from DST to standard time on 4 November 2012:\n");

            // Create a DateTimeFormatter to display dates
            DateTimeFormatter displayDate = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longdate");

            // Create a gregorian calendar for the US with 12-hour clock format
            Calendar currentCal = new Windows.Globalization.Calendar(new string[] { "en-US" }, CalendarIdentifiers.Gregorian, ClockIdentifiers.TwentyFourHour, "america/los_angeles");

            // Set the calendar to a the date of the Daylight Saving Time-to-Standard Time transition for the US in 2012.
            // DST ends in the US at 02:00 on 4 November 2012
            DateTime dstDate = new DateTime(2012, 11, 4);

            currentCal.SetDateTime(dstDate);

            // Set the current calendar to one day before DST change. Create a second calendar for comparision and set it to one day after DST change.
            Calendar endDate = currentCal.Clone();

            currentCal.AddDays(-1);
            endDate.AddDays(1);

            // Enumerate the day before, the day of, and the day after the 2012 DST-to-Standard time transition
            while (currentCal.Day <= endDate.Day)
            {
                // Process current day.
                DateTimeOffset date = currentCal.GetDateTime();
                results.AppendFormat("{0} contains {1} hour(s)\n", displayDate.Format(date), currentCal.NumberOfHoursInThisPeriod);

                // Enumerate all hours in this day.
                // Create a calendar to represent the following day.
                Calendar nextDay = currentCal.Clone();
                nextDay.AddDays(1);
                for (currentCal.Hour = currentCal.FirstHourInThisPeriod; true; currentCal.AddHours(1))
                {
                    // Display the hour for each hour in the day.
                    results.AppendFormat("{0} ", currentCal.HourAsPaddedString(2));

                    // Break upon reaching the next period (i.e. the first period in the following day).
                    if (currentCal.Day == nextDay.Day && currentCal.Period == nextDay.Period)
                    {
                        break;
                    }
                }

                results.AppendLine();
            }

            // Display results
            OutputTextBlock.Text = results.ToString();
        }