1
+
// Copyright © 2007 Andreas Gullberg Larsen ([email protected] ).
2
+ // https://github.com/anjdreas/UnitsNet
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ // of this software and associated documentation files (the "Software"), to deal
6
+ // in the Software without restriction, including without limitation the rights
7
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ // copies of the Software, and to permit persons to whom the Software is
9
+ // furnished to do so, subject to the following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included in
12
+ // all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ // THE SOFTWARE.
21
+
22
+ #if ! WINDOWS_UWP
23
+ // Extension methods/overloads not supported in Universal Windows Platform (WinRT Components)
24
+ using System ;
25
+
26
+ namespace UnitsNet . Extensions . Number
27
+ {
28
+ public static class NumberToTimeSpanExtensions
29
+ {
30
+ // ReSharper disable InconsistentNaming
31
+ /// <summary>Shorthand for <see cref="TimeSpan.FromDays" />.</summary>
32
+ public static TimeSpan d ( this int days ) => TimeSpan . FromDays ( days ) ;
33
+
34
+ /// <summary>Shorthand for <see cref="TimeSpan.FromDays" />.</summary>
35
+ public static TimeSpan d ( this long days ) => TimeSpan . FromDays ( days ) ;
36
+
37
+ /// <summary>Shorthand for <see cref="TimeSpan.FromDays" />.</summary>
38
+ public static TimeSpan d ( this float days ) => TimeSpan . FromDays ( days ) ;
39
+
40
+ /// <summary>Shorthand for <see cref="TimeSpan.FromDays" />.</summary>
41
+ public static TimeSpan d ( this double days ) => TimeSpan . FromDays ( days ) ;
42
+
43
+ /// <summary>Shorthand for <see cref="TimeSpan.FromDays" />.</summary>
44
+ public static TimeSpan d ( this decimal days ) => TimeSpan . FromDays ( Convert . ToDouble ( days ) ) ;
45
+
46
+ /// <summary>Shorthand for <see cref="TimeSpan.FromHours" />.</summary>
47
+ public static TimeSpan h ( this int hours ) => TimeSpan . FromHours ( hours ) ;
48
+
49
+ /// <summary>Shorthand for <see cref="TimeSpan.FromHours" />.</summary>
50
+ public static TimeSpan h ( this long hours ) => TimeSpan . FromHours ( hours ) ;
51
+
52
+ /// <summary>Shorthand for <see cref="TimeSpan.FromHours" />.</summary>
53
+ public static TimeSpan h ( this float hours ) => TimeSpan . FromHours ( hours ) ;
54
+
55
+ /// <summary>Shorthand for <see cref="TimeSpan.FromHours" />.</summary>
56
+ public static TimeSpan h ( this double hours ) => TimeSpan . FromHours ( hours ) ;
57
+
58
+ /// <summary>Shorthand for <see cref="TimeSpan.FromHours" />.</summary>
59
+ public static TimeSpan h ( this decimal hours ) => TimeSpan . FromHours ( Convert . ToDouble ( hours ) ) ;
60
+
61
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMinutes" />.</summary>
62
+ public static TimeSpan m ( this int minutes ) => TimeSpan . FromMinutes ( minutes ) ;
63
+
64
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMinutes" />.</summary>
65
+ public static TimeSpan m ( this long minutes ) => TimeSpan . FromMinutes ( minutes ) ;
66
+
67
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMinutes" />.</summary>
68
+ public static TimeSpan m ( this float minutes ) => TimeSpan . FromMinutes ( minutes ) ;
69
+
70
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMinutes" />.</summary>
71
+ public static TimeSpan m ( this double minutes ) => TimeSpan . FromMinutes ( minutes ) ;
72
+
73
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMinutes" />.</summary>
74
+ public static TimeSpan m ( this decimal minutes ) => TimeSpan . FromMinutes ( Convert . ToDouble ( minutes ) ) ;
75
+
76
+ /// <summary>Shorthand for <see cref="TimeSpan.FromSeconds" />.</summary>
77
+ public static TimeSpan s ( this int seconds ) => TimeSpan . FromSeconds ( seconds ) ;
78
+
79
+ /// <summary>Shorthand for <see cref="TimeSpan.FromSeconds" />.</summary>
80
+ public static TimeSpan s ( this long seconds ) => TimeSpan . FromSeconds ( seconds ) ;
81
+
82
+ /// <summary>Shorthand for <see cref="TimeSpan.FromSeconds" />.</summary>
83
+ public static TimeSpan s ( this float seconds ) => TimeSpan . FromSeconds ( seconds ) ;
84
+
85
+ /// <summary>Shorthand for <see cref="TimeSpan.FromSeconds" />.</summary>
86
+ public static TimeSpan s ( this double seconds ) => TimeSpan . FromSeconds ( seconds ) ;
87
+
88
+ /// <summary>Shorthand for <see cref="TimeSpan.FromSeconds" />.</summary>
89
+ public static TimeSpan s ( this decimal seconds ) => TimeSpan . FromSeconds ( Convert . ToDouble ( seconds ) ) ;
90
+
91
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMilliseconds" />.</summary>
92
+ public static TimeSpan ms ( this int milliseconds ) => TimeSpan . FromMilliseconds ( milliseconds ) ;
93
+
94
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMilliseconds" />.</summary>
95
+ public static TimeSpan ms ( this long milliseconds ) => TimeSpan . FromMilliseconds ( milliseconds ) ;
96
+
97
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMilliseconds" />.</summary>
98
+ public static TimeSpan ms ( this float milliseconds ) => TimeSpan . FromMilliseconds ( milliseconds ) ;
99
+
100
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMilliseconds" />.</summary>
101
+ public static TimeSpan ms ( this double milliseconds ) => TimeSpan . FromMilliseconds ( milliseconds ) ;
102
+
103
+ /// <summary>Shorthand for <see cref="TimeSpan.FromMilliseconds" />.</summary>
104
+ public static TimeSpan ms ( this decimal milliseconds ) => TimeSpan . FromMilliseconds ( Convert . ToDouble ( milliseconds ) ) ;
105
+
106
+ // ReSharper restore InconsistentNaming
107
+ }
108
+ }
109
+
110
+ #endif
0 commit comments