GetMonthAndDay() public static méthode

Gets the month and day from a T:System.DateTime object.
public static GetMonthAndDay ( System.DateTime dt ) : string
dt System.DateTime Date information.
Résultat string
        /// <summary>
        /// Converts a
        /// <see cref="T:System.DateTime"/>
        /// object into a string appropriately formatted for hourly feeds.
        /// This format can be found in messaging.
        /// </summary>
        /// <param name="value">The given date and time.</param>
        /// <param name="targetType">
        /// The type corresponding to the binding property, which must be of
        /// <see cref="T:System.String"/>.
        /// </param>
        /// <param name="parameter">(Not used).</param>
        /// <param name="culture">(Not used).</param>
        /// <returns>The given date and time as a string.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Target value must be a System.DateTime object.
            if (!(value is DateTime))
            {
                throw new ArgumentException(Properties.Resources.InvalidDateTimeArgument);
            }

            StringBuilder result = new StringBuilder(string.Empty);

            DateTime given = (DateTime)value;

            DateTime current = DateTime.Now;

            if (DateTimeFormatHelper.IsFutureDateTime(current, given))
            {
                // Future dates and times are not supported.
                throw new NotSupportedException(Properties.Resources.NonSupportedDateTime);
            }

            if (DateTimeFormatHelper.IsAnOlderYear(current, given))
            {
                result.AppendFormat(CultureInfo.CurrentCulture, "{0}, {1}",
                                    DateTimeFormatHelper.GetShortDate(given),
                                    DateTimeFormatHelper.GetSuperShortTime(given));
            }
            else if (DateTimeFormatHelper.IsAnOlderWeek(current, given))
            {
                result.AppendFormat(CultureInfo.CurrentCulture, "{0}, {1}",
                                    DateTimeFormatHelper.GetMonthAndDay(given),
                                    DateTimeFormatHelper.GetSuperShortTime(given));
            }
            else if (DateTimeFormatHelper.IsPastDayOfWeekWithWindow(current, given))
            {
                result.AppendFormat(CultureInfo.CurrentCulture, "{0}, {1}",
                                    DateTimeFormatHelper.GetAbbreviatedDay(given),
                                    DateTimeFormatHelper.GetSuperShortTime(given));
            }
            else
            {
                // Given day time is today.
                result.Append(DateTimeFormatHelper.GetSuperShortTime(given));
            }

            if (DateTimeFormatHelper.IsCurrentUICultureFrench())
            {
                result.Replace(",", string.Empty);
            }

            return(result.ToString());
        }
        /// <summary>
        /// Converts a
        /// <see cref="T:System.DateTime"/>
        /// object into a string appropriately formatted to
        /// display full date and time information.
        /// This format can be found in email.
        /// </summary>
        /// <remarks>
        /// This format never displays the year.
        /// </remarks>
        /// <param name="value">The given date and time.</param>
        /// <param name="targetType">
        /// The type corresponding to the binding property, which must be of
        /// <see cref="T:System.String"/>.
        /// </param>
        /// <param name="parameter">(Not used).</param>
        /// <param name="culture">(Not used).</param>
        /// <returns>The given date and time as a string.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Target value must be a System.DateTime object.
            if (!(value is DateTime))
            {
                throw new ArgumentException(Properties.Resources.InvalidDateTimeArgument);
            }

            StringBuilder result = new StringBuilder(string.Empty);

            DateTime given = (DateTime)value;

            if (DateTimeFormatHelper.IsCurrentCultureJapanese() || DateTimeFormatHelper.IsCurrentCultureKorean())
            {
                result.AppendFormat(CultureInfo.CurrentCulture, "{0} {1} {2}",
                                    DateTimeFormatHelper.GetMonthAndDay(given),
                                    DateTimeFormatHelper.GetAbbreviatedDay(given),
                                    DateTimeFormatHelper.GetShortTime(given));
            }
            else if (DateTimeFormatHelper.IsCurrentCultureTurkish())
            {
                result.AppendFormat(CultureInfo.CurrentCulture, "{0}, {1} {2}",
                                    DateTimeFormatHelper.GetMonthAndDay(given),
                                    DateTimeFormatHelper.GetAbbreviatedDay(given),
                                    DateTimeFormatHelper.GetShortTime(given));
            }
            else
            {
                result.AppendFormat(CultureInfo.CurrentCulture, "{0} {1}, {2}",
                                    DateTimeFormatHelper.GetAbbreviatedDay(given),
                                    DateTimeFormatHelper.GetMonthAndDay(given),
                                    DateTimeFormatHelper.GetShortTime(given));
            }

            if (DateTimeFormatHelper.IsCurrentUICultureFrench())
            {
                result.Replace(",", string.Empty);
            }

            return(result.ToString());
        }
        /// <summary>
        /// Converts a
        /// <see cref="T:System.DateTime"/>
        /// object into a string appropriately formatted for list-views.
        /// This format can be found in email.
        /// </summary>
        /// <remarks>
        /// This format never displays the year.
        /// </remarks>
        /// <param name="value">The given date and time.</param>
        /// <param name="targetType">
        /// The type corresponding to the binding property, which must be of
        /// <see cref="T:System.String"/>.
        /// </param>
        /// <param name="parameter">(Not used).</param>
        /// <param name="culture">(Not used).</param>
        /// <returns>The given date and time as a string.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Target value must be a System.DateTime object.
            if (!(value is DateTime))
            {
                throw new ArgumentException(Properties.Resources.InvalidDateTimeArgument);
            }

            string result;

            DateTime given = (DateTime)value;

            DateTime current = DateTime.Now;

            if (DateTimeFormatHelper.IsFutureDateTime(current, given))
            {
                // Future dates and times are not supported.
                throw new NotSupportedException(Properties.Resources.NonSupportedDateTime);
            }

            if (DateTimeFormatHelper.IsAnOlderWeek(current, given))
            {
                result = DateTimeFormatHelper.GetMonthAndDay(given);
            }
            else if (DateTimeFormatHelper.IsPastDayOfWeek(current, given))
            {
                result = DateTimeFormatHelper.GetAbbreviatedDay(given);
            }
            else
            {
                // Given day time is today.
                result = DateTimeFormatHelper.GetSuperShortTime(given);
            }

            return(result);
        }