Esempio n. 1
0
        /// <summary>
        /// <paramref name="timeSpan"/>을 문자열로 표현합니다.
        /// </summary>
        public string GetDuration(TimeSpan timeSpan, DurationFormatKind? durationFormatKind) {
            switch(durationFormatKind.GetValueOrDefault(DurationFormatKind.Compact)) {
                case DurationFormatKind.Detailed:
                    var days = timeSpan.TotalDays.AsInt(0);
                    var hours = timeSpan.Hours;
                    var minutes = timeSpan.Minutes;
                    var seconds = UseDurationSeconds ? timeSpan.Seconds : 0;
                    return GetDuration(0, 0, days, hours, minutes, seconds);

                case DurationFormatKind.Compact:
                default:
                    return UseDurationSeconds
                               ? string.Format("{0}.{1:00}:{2:00}:{3:00}", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes,
                                               timeSpan.Seconds)
                               : string.Format("{0}.{1:00}:{2:00}", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes);
            }
        }