• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / EntityChange / 10792597827

10 Sep 2024 12:38PM UTC coverage: 39.608%. Remained the same
10792597827

push

github

web-flow
Merge pull request #103 from loresoft/dependabot/nuget/MinVer-6.0.0

Bump MinVer from 5.0.0 to 6.0.0

237 of 731 branches covered (32.42%)

Branch coverage included in aggregate %.

571 of 1309 relevant lines covered (43.62%)

60.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.0
/src/EntityChange/StringFormatter.cs
1
namespace EntityChange;
2

3
/// <summary>
4
/// Standard string format options
5
/// </summary>
6
public static class StringFormatter
7
{
8
    /// <summary>
9
    /// Format the specified <paramref name="value"/> as a Currency.
10
    /// </summary>
11
    /// <param name="value">The value to format.</param>
12
    /// <returns></returns>
13
    public static string Currency(object value)
14
    {
15
        if (value == null)
3!
16
            return null;
×
17

18
        if (value is not IConvertible)
3!
19
            return value.ToString();
×
20

21
        var d = Convert.ToDecimal(value);
3✔
22
        return d.ToString("C");
3✔
23
    }
24

25
    /// <summary>
26
    /// Format the specified <paramref name="value"/> as a Number.
27
    /// </summary>
28
    /// <param name="value">The value to format.</param>
29
    /// <returns></returns>
30
    public static string Number(object value)
31
    {
32
        if (value == null)
3!
33
            return null;
×
34

35
        if (value is not IConvertible)
3!
36
            return value.ToString();
×
37

38
        var d = Convert.ToDecimal(value);
3✔
39
        return d.ToString("N2");
3✔
40
    }
41

42

43
    /// <summary>
44
    /// Format the specified <paramref name="value"/> as a Short Date pattern.
45
    /// </summary>
46
    /// <param name="value">The value to format.</param>
47
    /// <returns></returns>
48
    public static string ShortDate(object value)
49
    {
50
        if (value == null)
×
51
            return null;
×
52

53
        if (value is not IConvertible)
×
54
            return value.ToString();
×
55

56
        var d = Convert.ToDateTime(value);
×
57
        return d.ToString("d");
×
58
    }
59

60
    /// <summary>
61
    /// Format the specified <paramref name="value"/> as a Long Date pattern.
62
    /// </summary>
63
    /// <param name="value">The value to format.</param>
64
    /// <returns></returns>
65
    public static string LongDate(object value)
66
    {
67
        if (value == null)
×
68
            return null;
×
69

70
        if (value is not IConvertible)
×
71
            return value.ToString();
×
72

73
        var d = Convert.ToDateTime(value);
×
74
        return d.ToString("D");
×
75
    }
76

77
    /// <summary>
78
    /// Format the specified <paramref name="value"/> as a Full Date Short Time pattern.
79
    /// </summary>
80
    /// <param name="value">The value to format.</param>
81
    /// <returns></returns>
82
    public static string FullDateShortTime(object value)
83
    {
84
        if (value == null)
×
85
            return null;
×
86

87
        if (value is not IConvertible)
×
88
            return value.ToString();
×
89

90
        var d = Convert.ToDateTime(value);
×
91
        return d.ToString("f");
×
92
    }
93

94
    /// <summary>
95
    /// Format the specified <paramref name="value"/> as a Full Date Long Time pattern.
96
    /// </summary>
97
    /// <param name="value">The value to format.</param>
98
    /// <returns></returns>
99
    public static string FullDateLongTime(object value)
100
    {
101
        if (value == null)
×
102
            return null;
×
103

104
        if (value is not IConvertible)
×
105
            return value.ToString();
×
106

107
        var d = Convert.ToDateTime(value);
×
108
        return d.ToString("F");
×
109
    }
110

111
    /// <summary>
112
    /// Format the specified <paramref name="value"/> as a General Date Short Time pattern.
113
    /// </summary>
114
    /// <param name="value">The value to format.</param>
115
    /// <returns></returns>
116
    public static string GeneralDateShortTime(object value)
117
    {
118
        if (value == null)
×
119
            return null;
×
120

121
        if (value is not IConvertible)
×
122
            return value.ToString();
×
123

124
        var d = Convert.ToDateTime(value);
×
125
        return d.ToString("g");
×
126
    }
127

128
    /// <summary>
129
    /// Format the specified <paramref name="value"/> as a General Date Long Time pattern.
130
    /// </summary>
131
    /// <param name="value">The value to format.</param>
132
    /// <returns></returns>
133
    public static string GeneralDateLongTime(object value)
134
    {
135
        if (value == null)
×
136
            return null;
×
137

138
        if (value is not IConvertible)
×
139
            return value.ToString();
×
140

141
        var d = Convert.ToDateTime(value);
×
142
        return d.ToString("G");
×
143
    }
144

145
    /// <summary>
146
    /// Format the specified <paramref name="value"/> as a Short Time pattern.
147
    /// </summary>
148
    /// <param name="value">The value to format.</param>
149
    /// <returns></returns>
150
    public static string ShortTime(object value)
151
    {
152
        if (value == null)
×
153
            return null;
×
154

155
        if (value is not IConvertible)
×
156
            return value.ToString();
×
157

158
        var d = Convert.ToDateTime(value);
×
159
        return d.ToString("t");
×
160
    }
161

162
    /// <summary>
163
    /// Format the specified <paramref name="value"/> as a Long Time pattern.
164
    /// </summary>
165
    /// <param name="value">The value to format.</param>
166
    /// <returns></returns>
167
    public static string LongTime(object value)
168
    {
169
        if (value == null)
×
170
            return null;
×
171

172
        if (value is not IConvertible)
×
173
            return value.ToString();
×
174

175
        var d = Convert.ToDateTime(value);
×
176
        return d.ToString("T");
×
177
    }
178
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc