Integer to Time Conversion
-
I need in a console application to have user input an integer in military time that be converted some how to 13:00 or 13:30 instead of 1330 the pure number.
So that I can then take 1330 and have the user input an end time like 1430 and increase it by 25 percent to come out with 1445 or 2:45. So your increases the total time from 1 hour to 1 hour and 15 minutes.
The input will always be HHMM in military time
Simple Function is needed nothing advanced
-
I need in a console application to have user input an integer in military time that be converted some how to 13:00 or 13:30 instead of 1330 the pure number.
So that I can then take 1330 and have the user input an end time like 1430 and increase it by 25 percent to come out with 1445 or 2:45. So your increases the total time from 1 hour to 1 hour and 15 minutes.
The input will always be HHMM in military time
Simple Function is needed nothing advanced
So what have you written? You seem to have the wrong idea what this forum is for, we help budding developers improve their skills and learn, we do not supply solutions, that is your job. There are other sites that will supply the solution for a minimal payment, you may want to try there!
Never underestimate the power of human stupidity RAH
-
I need in a console application to have user input an integer in military time that be converted some how to 13:00 or 13:30 instead of 1330 the pure number.
So that I can then take 1330 and have the user input an end time like 1430 and increase it by 25 percent to come out with 1445 or 2:45. So your increases the total time from 1 hour to 1 hour and 15 minutes.
The input will always be HHMM in military time
Simple Function is needed nothing advanced
-
-
Your darn right its homework. Seeing as original thought doesn't exist and I have spent the better part of the day wrestling with this. I reached out to the community for insight.
If that's the better part I don't want to see the worse part. :-D
-
I need in a console application to have user input an integer in military time that be converted some how to 13:00 or 13:30 instead of 1330 the pure number.
So that I can then take 1330 and have the user input an end time like 1430 and increase it by 25 percent to come out with 1445 or 2:45. So your increases the total time from 1 hour to 1 hour and 15 minutes.
The input will always be HHMM in military time
Simple Function is needed nothing advanced
I think the following points may be helpful. Use
DateTime.ParseExact
to parse the timeDateTime startTime = DateTime.ParseExact("1330","HHmm",
System.Globalization.CultureInfo.InstalledUICulture);similarly parse the end time. Now find the duration between
end time and start time
using theSubtract
method ofDateTime
object which returns aTimeSpan
object. Then get the total minutes using theTotalMinutes
method ofTimeSpan
object. Use theAddMinutes
method ofDateTime
to add minutes to the end time Then get the string representation of modified end time usingstring endTimeString = endTime.ToString("HHmm",
System.Globalization.CultureInfo.InvariantCulture);