In the days of VB.NET I used to use two drop-downs to determine the hour and the minute of an import via the following manner:
For i As Integer = 0 To 23
ddlHour.Items.Add(New ListItem(String.Format("{0:0#}", i), i.ToString()))
Next
For i As Integer = 0 To 45 Step 15
ddlMinute.Items.Add(New ListItem(String.Format("{0:0#}", i), i.ToString()))
Next
I’ve had a play with the TimeSpan object and found an easy way to print the hours and mins using c#
private List LoadHours(int NumberOfMinutes) { var ts = TimeSpan.Zero; var ts_end =TimeSpan.FromDays(1); var lstReturn = new List(); while (ts<ts_end) { lstReturn.Add(ts.ToString(@"hh\:mm")); //continue ts = ts.Add(TimeSpan.FromMinutes(NumberOfMinutes)); } return lstReturn; }
Advertisements