3
Is there a library specializing in the handling of quantities and units of time?
Allowing the conversion of/into milliseconds, seconds, minutes and time sum and subtraction operations.
Native in c#
I found nothing that does not require much effort and conversion calculations.
Or if it exists natively how could it obtain the total of hours by adding two amounts of time, for example:
03:20 + 03:50 = ?
There is a way to do this without having to untangle the hours and minutes, making validations for when the minutes pass 59 become an hour more?
Yes, there is FCL https://en.wikipedia.org/wiki/Standard_Libraries_(CLI)
– Maniero
Give me an example of how I do the sum of hours with FCL please. for example add
00:59 + 00:40
– Jhonatan Jorge de Lima
Hours cannot be summed up, this makes no sense, hours are points in time.
– Maniero
@Meajudasilvio I don’t know if I got it right, but it would be something like that?
– Randrade
@Randrade is exactly that, thank you very much, can by as an answer, and if possible give an explanation to our friend of how it is possible to add "two points in time"
– Jhonatan Jorge de Lima
@Meajudasilvio Your question is currently closed and cannot be answered. You can [Dit] the question explaining the best for it to be reopened. It would be useful for you to add a clearer example question, such as "How to get the total hours by adding two hours, for example:
03:20
+03:50
? I think it would make it clearer and it could be reopened.– Randrade
@Meajudasilvio See if this example helps you: https://dotnetfiddle.net/YQkmqF
– Rodolpho Sa
You asked for the library and I showed you, if you didn’t want to know that, don’t ask. https://msdn.microsoft.com/en-us/library/system.datetime(v=vs.110). aspx This is the timekeeping object. Look at the summation methods and look for one that adds up to two times. It does not. Do you think Microsoft forgot to put it? She didn’t put it because it doesn’t make sense. Shows me an operation where you need to add an input and an output point and what the expected result is. This does not exist.
– Maniero
http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-abouttime, http://infiniteundo.com/post/25509354022/more-falsehoods-programmers-believe-abouttime (has more than 100 things that most people think they know about and don’t. https://en.wikipedia.org/wiki/Time If you improve your question as everyone has indicated it may be reopened, complaining is not possible. Inform what you really want, add two hours is not possible.
– Maniero
What @bigown said about not being able to "add hours" makes sense, if you remember that hours are not integer numerical values, you don’t apply arithmetic operations directly over hours. You need to convert to arrive at something like "sum of hours". Perhaps the best way to do this simply is to adopt the same pattern used in Unix: convert the hours into seconds, do the operations (sum, subtraction, etc...) with the seconds and then convert them back. This way you ensure the result and it is not difficult to implement. (Something simple, of course.)
– nmindz
Blz. Thank you..
– Jhonatan Jorge de Lima
That question is being debated at the goal
– Randrade
@Meajudasilvio If the edition I made does not match what I intended to ask, please reverse it or say that I do.
– ramaral
In my view it has become much more coherent, thank you very much for your help.
– Jhonatan Jorge de Lima