Itenso.TimePeriod.TimeRange.GetDescription C# (CSharp) Method

GetDescription() public method

public GetDescription ( ITimeFormatter formatter = null ) : string
formatter ITimeFormatter
return string
        public string GetDescription( ITimeFormatter formatter = null )
        {
            return Format( formatter ?? TimeFormatter.Instance );
        }

Usage Example

Example #1
0
        public void TimeFormatterSample()
        {
            DateTime start = new DateTime( 2011, 1, 28, 18, 45, 0 );
            DateTime end = new DateTime( 2012, 1, 1 );
            TimeRange timeRange = new TimeRange( start, end );

            // use default formatter
            Console.WriteLine( "TimeRange.GetDescription: " + timeRange.GetDescription() );
            // > TimeRange.GetDescription: 28.01.2011 18:45:00 - 01.01.2012 00:00:00 | 337.05:15

            // custom formatter (named parameters)
            TimeFormatter timeFormatter = new TimeFormatter(
                startEndSeparator: "...",
                durationType: DurationFormatType.Detailed,
                dateTimeFormat: "D" );

            // use custom formatter (named parameters)
            Console.WriteLine( "TimeRange.GetDescription: " + timeRange.GetDescription( timeFormatter ) );
            // > TimeRange.GetDescription: Freitag, 28. Januar 2011...Sonntag, 1. Januar 2012 | 337 days 5 hours 15 mins
        }