Пример #1
0
        // Token: 0x060000E9 RID: 233 RVA: 0x00003758 File Offset: 0x00001958
        private static int GetTimeUnitNumericalValue(TimeUnit timeUnitToGet, TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit)
        {
            switch (timeUnitToGet)
            {
            case TimeUnit.Millisecond:
                return(TimeSpanHumanizeExtensions.GetNormalCaseTimeAsInteger(timespan.Milliseconds, timespan.TotalMilliseconds, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Second:
                return(TimeSpanHumanizeExtensions.GetNormalCaseTimeAsInteger(timespan.Seconds, timespan.TotalSeconds, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Minute:
                return(TimeSpanHumanizeExtensions.GetNormalCaseTimeAsInteger(timespan.Minutes, timespan.TotalMinutes, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Hour:
                return(TimeSpanHumanizeExtensions.GetNormalCaseTimeAsInteger(timespan.Hours, timespan.TotalHours, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Day:
                return(TimeSpanHumanizeExtensions.GetSpecialCaseDaysAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Week:
                return(TimeSpanHumanizeExtensions.GetSpecialCaseWeeksAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Month:
                return(TimeSpanHumanizeExtensions.GetSpecialCaseMonthAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit));

            case TimeUnit.Year:
                return(TimeSpanHumanizeExtensions.GetSpecialCaseYearAsInteger(timespan));

            default:
                return(0);
            }
        }
Пример #2
0
 // Token: 0x060000E8 RID: 232 RVA: 0x00003728 File Offset: 0x00001928
 private static string GetTimeUnitPart(TimeUnit timeUnitToGet, TimeSpan timespan, CultureInfo culture, TimeUnit maximumTimeUnit, TimeUnit minimumTimeUnit, IFormatter cultureFormatter)
 {
     if (timeUnitToGet <= maximumTimeUnit && timeUnitToGet >= minimumTimeUnit)
     {
         bool isTimeUnitToGetTheMaximumTimeUnit = timeUnitToGet == maximumTimeUnit;
         int  numberOfTimeUnits = TimeSpanHumanizeExtensions.GetTimeUnitNumericalValue(timeUnitToGet, timespan, isTimeUnitToGetTheMaximumTimeUnit);
         return(TimeSpanHumanizeExtensions.BuildFormatTimePart(cultureFormatter, timeUnitToGet, numberOfTimeUnits));
     }
     return(null);
 }
Пример #3
0
        // Token: 0x060000E6 RID: 230 RVA: 0x00003684 File Offset: 0x00001884
        private static IEnumerable <string> CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan timespan, CultureInfo culture, TimeUnit maxUnit, TimeUnit minUnit)
        {
            IFormatter             cultureFormatter     = Configurator.GetFormatter(culture);
            bool                   firstValueFound      = false;
            IEnumerable <TimeUnit> enumTypesForTimeUnit = TimeSpanHumanizeExtensions.GetEnumTypesForTimeUnit();
            List <string>          timeParts            = new List <string>();

            foreach (TimeUnit timeUnitToGet in enumTypesForTimeUnit)
            {
                string timepart = TimeSpanHumanizeExtensions.GetTimeUnitPart(timeUnitToGet, timespan, culture, maxUnit, minUnit, cultureFormatter);
                if (timepart != null || firstValueFound)
                {
                    firstValueFound = true;
                    timeParts.Add(timepart);
                }
            }
            if (TimeSpanHumanizeExtensions.IsContainingOnlyNullValue(timeParts))
            {
                timeParts = TimeSpanHumanizeExtensions.CreateTimePartsWithNoTimeValue(cultureFormatter.TimeSpanHumanize_Zero());
            }
            return(timeParts);
        }
Пример #4
0
 // Token: 0x060000E5 RID: 229 RVA: 0x00003666 File Offset: 0x00001866
 public static string Humanize(this TimeSpan timeSpan, int precision, bool countEmptyUnits, CultureInfo culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string collectionSeparator = ", ")
 {
     return(TimeSpanHumanizeExtensions.ConcatenateTimeSpanParts(TimeSpanHumanizeExtensions.SetPrecisionOfTimeSpan(TimeSpanHumanizeExtensions.CreateTheTimePartsWithUpperAndLowerLimits(timeSpan, culture, maxUnit, minUnit), precision, countEmptyUnits), collectionSeparator));
 }