File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/jcdcdev.Umbraco.ReadingTime/Core/PropertyEditors Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,16 @@ public class ReadingTimeConfiguration
2020 public TimeUnit Min => ( TimeUnit ) MinUnit ;
2121 public TimeUnit Max => ( TimeUnit ) MaxUnit ;
2222
23- public static TimeSpan GetReadingTime ( TimeSpan ? readingTime , TimeUnit min ) => min switch
23+ public static TimeSpan GetReadingTime ( TimeSpan ? readingTime , TimeUnit min )
2424 {
25- TimeUnit . Second => readingTime . GetValueOrDefault ( TimeSpan . FromSeconds ( 1 ) ) ,
26- TimeUnit . Minute => readingTime . GetValueOrDefault ( TimeSpan . FromMinutes ( 1 ) ) ,
27- TimeUnit . Hour => readingTime . GetValueOrDefault ( TimeSpan . FromHours ( 1 ) ) ,
28- TimeUnit . Day => readingTime . GetValueOrDefault ( TimeSpan . FromDays ( 1 ) ) ,
29- _ => readingTime . GetValueOrDefault ( TimeSpan . FromMinutes ( 1 ) )
30- } ;
25+ var time = readingTime . GetValueOrDefault ( ) ;
26+ return min switch
27+ {
28+ TimeUnit . Second => time < TimeSpan . FromSeconds ( 1 ) ? TimeSpan . FromSeconds ( 1 ) : time ,
29+ TimeUnit . Minute => time < TimeSpan . FromMinutes ( 1 ) ? TimeSpan . FromMinutes ( 1 ) : time ,
30+ TimeUnit . Hour => time < TimeSpan . FromHours ( 1 ) ? TimeSpan . FromHours ( 1 ) : time ,
31+ TimeUnit . Day => time < TimeSpan . FromDays ( 1 ) ? TimeSpan . FromDays ( 1 ) : time ,
32+ _ => time < TimeSpan . FromMinutes ( 1 ) ? TimeSpan . FromMinutes ( 1 ) : time
33+ } ;
34+ }
3135}
You can’t perform that action at this time.
0 commit comments