G
Guest
Hello,
I'm developing a large statistics application for a call center. It often needs to calculate time spanning over months. For example, an agent's total talk time within 30 days. Since an agent talks about 5 hours per day, this comes out to about 150 hours of talk time per month. Fine.
But, the DateTime and TimeSpan format strings will only output hours from 0-23. I need something that will output time as such:
150:0:0
to represent 150 hours, 0 minutes, and 0 seconds.
Is there any way to do this? I'm binding these values to a DataGrid, so it needs to be outputted in the above manner and not in the "6.6:0:0" that the TimeSpan ToString() method outputs.
I created a custom format provider by implementing the ICustomFormatter and ICustomProvider interfaces, but this is not my preferred solution. There must be some way to do this, alternatively, that I am overlooking? Thanks for your assistance.
Regards,
Jeffrey Shantz MCP
P.S. (The reason that using a CustomerFormatter is not my preferred solution is this:
I need a summary row at the bottom of the datagrid calculating the totals of all the times listed in the datagrid rows. I keep a running total by incrementing in the ItemDataBound() event and then display that running total in the footer (the summary row). All fine, except that the ItemDataBound() event fires *after* each row is added, meaning that I have to do something like this: mRunningTotal += TimeSpan.Parse(e.Item.Cells[0].Text). The problem is that if the cell text is formatted using my custom formatter, it will be outputted something like this: "150:0:0". But the TimeSpan.Parse() method only allows for 0-23 hours, so it throws an Exception.
This may not make much sense to you outside the scope of my project, but this explanation was just provided for a little background info)
I'm developing a large statistics application for a call center. It often needs to calculate time spanning over months. For example, an agent's total talk time within 30 days. Since an agent talks about 5 hours per day, this comes out to about 150 hours of talk time per month. Fine.
But, the DateTime and TimeSpan format strings will only output hours from 0-23. I need something that will output time as such:
150:0:0
to represent 150 hours, 0 minutes, and 0 seconds.
Is there any way to do this? I'm binding these values to a DataGrid, so it needs to be outputted in the above manner and not in the "6.6:0:0" that the TimeSpan ToString() method outputs.
I created a custom format provider by implementing the ICustomFormatter and ICustomProvider interfaces, but this is not my preferred solution. There must be some way to do this, alternatively, that I am overlooking? Thanks for your assistance.
Regards,
Jeffrey Shantz MCP
P.S. (The reason that using a CustomerFormatter is not my preferred solution is this:
I need a summary row at the bottom of the datagrid calculating the totals of all the times listed in the datagrid rows. I keep a running total by incrementing in the ItemDataBound() event and then display that running total in the footer (the summary row). All fine, except that the ItemDataBound() event fires *after* each row is added, meaning that I have to do something like this: mRunningTotal += TimeSpan.Parse(e.Item.Cells[0].Text). The problem is that if the cell text is formatted using my custom formatter, it will be outputted something like this: "150:0:0". But the TimeSpan.Parse() method only allows for 0-23 hours, so it throws an Exception.
This may not make much sense to you outside the scope of my project, but this explanation was just provided for a little background info)