< Summary

Information
Class: MyNet.Humanizer.Temporal.TimeHumanizationPresets
Assembly: MyNet.Humanizer
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Humanizer/Temporal/TimeHumanizationPresets.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 39
Uncovered lines: 0
Coverable lines: 39
Total lines: 90
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Humanizer/Temporal/TimeHumanizationPresets.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="TimeHumanizationPresets.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using MyNet.Primitives;
 8using MyNet.Temporal.Decomposition;
 9
 10namespace MyNet.Humanizer.Temporal;
 11
 12/// <summary>
 13/// Provides preset configurations for <see cref="TimeSpanDecompositionOptions"/>.
 14/// </summary>
 15public static class TimeHumanizationPresets
 16{
 17    /// <summary>
 18    /// Gets the default humanization options, which is the same as <see cref="Duration"/>.
 19    /// </summary>
 320    public static TimeHumanizationOptions Default { get; } = new()
 321    {
 322        Mode = TimeHumanizationMode.Duration,
 323        MaxComponents = 2,
 324        MinUnit = TimeUnit.Second,
 325        MaxUnit = TimeUnit.Year,
 326        DecompositionMode = TimeSpanDecompositionMode.Hierarchical
 327    };
 28
 29    /// <summary>
 30    /// Gets human-readable duration with up to 2 components.
 31    /// Example:
 32    /// 1 minute 59 seconds.
 33    /// </summary>
 334    public static TimeHumanizationOptions Duration { get; } = new()
 335    {
 336        Mode = TimeHumanizationMode.Duration,
 337        MaxComponents = 2,
 338        MinUnit = TimeUnit.Second,
 339        MaxUnit = TimeUnit.Year,
 340        DecompositionMode = TimeSpanDecompositionMode.Hierarchical
 341    };
 42
 43    /// <summary>
 44    /// Gets human-readable relative time with a single component.
 45    /// Example:
 46    /// 1 minute ago.
 47    /// </summary>
 348    public static TimeHumanizationOptions Relative { get; } = new()
 349    {
 350        Mode = TimeHumanizationMode.Relative,
 351        MaxComponents = 1,
 352        Quantizer = HumanFriendlyTimeSpanQuantizer.Default
 353    };
 54
 55    /// <summary>
 56    /// Gets exact human-readable decomposition.
 57    /// Example:
 58    /// 1 minute 59 seconds.
 59    /// </summary>
 360    public static TimeHumanizationOptions Precise { get; } = new()
 361    {
 362        Mode = TimeHumanizationMode.Duration,
 363        MaxComponents = null,
 364        IncludeZeroUnits = false
 365    };
 66
 67    /// <summary>
 68    /// Gets human-friendly approximation.
 69    /// Example:
 70    /// 59 seconds -> 1 minute.
 71    /// </summary>
 372    public static TimeHumanizationOptions Fuzzy { get; } = new()
 373    {
 374        Mode = TimeHumanizationMode.Relative,
 375        MaxComponents = 1,
 376        Quantizer = HumanFriendlyTimeSpanQuantizer.Default
 377    };
 78
 79    /// <summary>
 80    /// Gets compact UI-oriented representation.
 81    /// Example:
 82    /// 2h.
 83    /// </summary>
 384    public static TimeHumanizationOptions Compact { get; } = new()
 385    {
 386        Mode = TimeHumanizationMode.Duration,
 387        MaxComponents = 1
 388    };
 89}
 90

Methods/Properties

.cctor()