FogBugz » FogBugz for Visual Studio Read More
Clone URL:  
Estimate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System; using System.Collections.Generic; using System.Globalization; using System.Text; namespace FogBugzForVisualStudio.Api { public class Estimate { public decimal hrs { get; private set; } public Estimate(decimal hrs) { this.hrs = hrs; } public static Estimate Parse(String s) { return new Estimate(Convert.ToDecimal(s, CultureInfo.InvariantCulture)); } public override string ToString() { if (hrs == 0) return ""; // Based on SFromHours in util.was int nHours = Convert.ToInt32(Decimal.Floor(hrs)); int nMinutes = Convert.ToInt32(Decimal.Floor((hrs - nHours) * 60)); if (nHours == 0 && nMinutes == 0) { return "0 hours"; } else if (nHours == 0) { return nMinutes == 1 ? "1 minute" : (nMinutes + " minutes"); } else { double h = Math.Round(nHours + nMinutes/60.0, 2); return h == 1 ? "1 hour" : (h + " hours"); } } } }