} // FormatTimeOfDay private static string FormatTimeTokenHour ( DateTime pdtmTheTime , HoursFormatType penmHoursFormatType ) { switch ( penmHoursFormatType ) { case HoursFormatType.Civilian: if ( pdtmTheTime.Hour < HOUR_NOON ) return pdtmTheTime.Hour.ToString ( TOSTRING_MDHMS ); else return ( pdtmTheTime.Hour - HOUR_NOON ).ToString ( TOSTRING_MDHMS ); case HoursFormatType.CultureInfoShortTime: return SpecialStrings.EMPTY_STRING; case HoursFormatType.Military: return pdtmTheTime.Hour.ToString ( TOSTRING_MDHMS ); default: throw new ArgumentOutOfRangeException ( ARG_NAME_HRSFMTTYP , InvalidEnumArgValueMessage ( ARG_NAME_HRSFMTTYP , ( int ) penmHoursFormatType ) ); } // switch ( penmHoursFormatType ) } // FormatTimeTokenHour
} // FormatAMPMToken private static string FormatTimeOfDay ( DateTime pdtmTheTime , HoursFormatType penmHoursFormatType , TimePrecisionType penmTimePrecisionType , bool pfShowAmPmAsUC ) { if ( penmHoursFormatType == HoursFormatType.CultureInfoShortTime ) return pdtmTheTime.ToShortTimeString ( ); else return string.Format ( _astrTimeOfDayFormat [ ( int ) penmHoursFormatType ] , // Message Template new string [ ] { FormatTimeTokenHour( pdtmTheTime , penmHoursFormatType ) , // Token 0 pdtmTheTime.Minute.ToString ( TOSTRING_MDHMS ) , // Token 1 FormatTimeTokenSeconds ( pdtmTheTime , penmTimePrecisionType ) , // Token 2 FormatTimeTokenMilliseconds ( pdtmTheTime , penmTimePrecisionType ) , // Token 3 FromatTimeTokenTicks ( pdtmTheTime , penmTimePrecisionType ) , // Token 4 FormatAMPMToken ( pdtmTheTime , penmHoursFormatType, pfShowAmPmAsUC)} ); // Token 5 } // FormatTimeOfDay
} // PrepareLocalAndUTCTimes #endregion // Public Methods #region Private Static Methods private static string FormatTheTime ( DateTime pdtmTheTime , DateFieldOrder penmDateFieldOrder , HoursFormatType penmHoursFormatType , TimePrecisionType penmTimePrecisionType , bool pfShowTimeZone , bool pfShowWeekdayName , bool pfShowAmPmAsUC ) { string strFormattedCalendarDate = FormatCalendarDate ( pdtmTheTime , penmDateFieldOrder ); string strFormattedTimeOfDay = FormatTimeOfDay ( pdtmTheTime , penmHoursFormatType , penmTimePrecisionType , pfShowAmPmAsUC ); return string.Format ( FMT_DATE_AND_TIME , // Message Template new string [ ]{ FormatWeekdayNameDisplay( pdtmTheTime , pfShowWeekdayName ) , // Token 0 strFormattedCalendarDate , // Token 1 strFormattedTimeOfDay, // Token 2 FormatTimeZoneDisplay( pdtmTheTime , pfShowTimeZone)} ); // Token 3 } // EFormatTheTime
} // FormatCalendarDate private static string FormatAMPMToken ( DateTime pdtmTheTime , HoursFormatType penmHoursFormatType , bool pfShowAmPmAsUC ) { switch ( penmHoursFormatType ) { case HoursFormatType.Civilian: if ( pdtmTheTime.Hour < HOUR_NOON ) if ( pfShowAmPmAsUC ) return string.Format ( FMT_AMPM , CIVILIAN_AM_UC ); else return string.Format ( FMT_AMPM , CIVILIAN_AM_LC ); else if ( pfShowAmPmAsUC ) return string.Format ( FMT_AMPM , CIVILIAN_PM_UC ); else return string.Format ( FMT_AMPM , CIVILIAN_PM_LC ); case HoursFormatType.CultureInfoShortTime: case HoursFormatType.Military: return SpecialStrings.EMPTY_STRING; default: throw new ArgumentOutOfRangeException ( ARG_NAME_HRSFMTTYP , InvalidEnumArgValueMessage ( ARG_NAME_HRSFMTTYP , ( int ) penmHoursFormatType ) ); } // switch ( penmHoursFormatType ) } // FormatAMPMToken