| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="TimeSpanDecompositionPresets.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using MyNet.Primitives; |
| | | 8 | | |
| | | 9 | | namespace MyNet.Temporal.Decomposition; |
| | | 10 | | |
| | | 11 | | public static class TimeSpanDecompositionPresets |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets strict decomposition: precise, no noise, no zero units. |
| | | 15 | | /// Best for logs, debugging, and technical output. |
| | | 16 | | /// </summary> |
| | 3 | 17 | | public static TimeSpanDecompositionOptions Strict { get; } = new() |
| | 3 | 18 | | { |
| | 3 | 19 | | MinUnit = TimeUnit.Millisecond, |
| | 3 | 20 | | MaxUnit = TimeUnit.Year, |
| | 3 | 21 | | Mode = TimeSpanDecompositionMode.Hierarchical, |
| | 3 | 22 | | MaxComponents = null, |
| | 3 | 23 | | IncludeZeroUnits = false, |
| | 3 | 24 | | RuleEngine = TimeUnitRuleSelector.Default, |
| | 3 | 25 | | Quantizer = null |
| | 3 | 26 | | }; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets human-friendly decomposition optimized for UI display. |
| | | 30 | | /// Limits output size and removes empty units. |
| | | 31 | | /// </summary> |
| | 3 | 32 | | public static TimeSpanDecompositionOptions Humanized { get; } = new() |
| | 3 | 33 | | { |
| | 3 | 34 | | MinUnit = TimeUnit.Second, |
| | 3 | 35 | | MaxUnit = TimeUnit.Year, |
| | 3 | 36 | | Mode = TimeSpanDecompositionMode.Hierarchical, |
| | 3 | 37 | | MaxComponents = 2, |
| | 3 | 38 | | IncludeZeroUnits = false, |
| | 3 | 39 | | RuleEngine = TimeUnitRuleSelector.Default, |
| | 3 | 40 | | Quantizer = null |
| | 3 | 41 | | }; |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Gets compact representation: best effort single or few units. |
| | | 45 | | /// Example: 2 weeks instead of 14 days 0 hours. |
| | | 46 | | /// </summary> |
| | 3 | 47 | | public static TimeSpanDecompositionOptions Compact { get; } = new() |
| | 3 | 48 | | { |
| | 3 | 49 | | MinUnit = TimeUnit.Minute, |
| | 3 | 50 | | MaxUnit = TimeUnit.Year, |
| | 3 | 51 | | Mode = TimeSpanDecompositionMode.LargestUnitOnly, |
| | 3 | 52 | | MaxComponents = 1, |
| | 3 | 53 | | IncludeZeroUnits = false, |
| | 3 | 54 | | RuleEngine = TimeUnitRuleSelector.Default, |
| | 3 | 55 | | Quantizer = null |
| | 3 | 56 | | }; |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Gets full breakdown: keeps all units, including zeros. |
| | | 60 | | /// Useful for debugging or UI grids. |
| | | 61 | | /// </summary> |
| | 3 | 62 | | public static TimeSpanDecompositionOptions Full { get; } = new() |
| | 3 | 63 | | { |
| | 3 | 64 | | MinUnit = TimeUnit.Millisecond, |
| | 3 | 65 | | MaxUnit = TimeUnit.Year, |
| | 3 | 66 | | Mode = TimeSpanDecompositionMode.Hierarchical, |
| | 3 | 67 | | MaxComponents = null, |
| | 3 | 68 | | IncludeZeroUnits = true, |
| | 3 | 69 | | RuleEngine = TimeUnitRuleSelector.Default, |
| | 3 | 70 | | Quantizer = null |
| | 3 | 71 | | }; |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Gets smallest unit representation: flattens into the smallest unit. |
| | | 75 | | /// Useful for comparisons, sorting, or storage. |
| | | 76 | | /// </summary> |
| | 3 | 77 | | public static TimeSpanDecompositionOptions SmallestUnit { get; } = new() |
| | 3 | 78 | | { |
| | 3 | 79 | | MinUnit = TimeUnit.Millisecond, |
| | 3 | 80 | | MaxUnit = TimeUnit.Year, |
| | 3 | 81 | | Mode = TimeSpanDecompositionMode.SmallestUnitOnly, |
| | 3 | 82 | | MaxComponents = 1, |
| | 3 | 83 | | IncludeZeroUnits = false, |
| | 3 | 84 | | RuleEngine = TimeUnitRuleSelector.Default, |
| | 3 | 85 | | Quantizer = null |
| | 3 | 86 | | }; |
| | | 87 | | |
| | | 88 | | /// <summary> |
| | | 89 | | /// Gets largest unit only representation. |
| | | 90 | | /// Example: 2 weeks instead of detailed breakdown. |
| | | 91 | | /// </summary> |
| | 3 | 92 | | public static TimeSpanDecompositionOptions LargestUnit { get; } = new() |
| | 3 | 93 | | { |
| | 3 | 94 | | MinUnit = TimeUnit.Millisecond, |
| | 3 | 95 | | MaxUnit = TimeUnit.Year, |
| | 3 | 96 | | Mode = TimeSpanDecompositionMode.LargestUnitOnly, |
| | 3 | 97 | | MaxComponents = 1, |
| | 3 | 98 | | IncludeZeroUnits = false, |
| | 3 | 99 | | RuleEngine = TimeUnitRuleSelector.Default, |
| | 3 | 100 | | Quantizer = null |
| | 3 | 101 | | }; |
| | | 102 | | } |
| | | 103 | | |