Thursday, July 30, 2009

I'm in C++ and I need to know how to change a decimal into time.?

Example is .75 is 18 out of 24 hours therefore the time is 6:00 p.m. Or .525 is 3:00 p.m. I would be grateful for any help.


Thanks

I'm in C++ and I need to know how to change a decimal into time.?
The question does not make sense. Are you always trying to turn a decimal value that is less than 1 into a 12-hour time (AM/PM)?





It would make more sense if the fraction represents the minutes of the hour, not the hour of the day, but you already described the answer if it represents the hour of the day. You multiply the fraction (must be less than 1 for this to work) by 24, then if the answer is greater than 12, subtract 12 to get the AM/PM time. Do you want to know how to determine the minutes of the hour if there is a remainder?





NEW: Well, I'm bending over backward here trying to help you, but it's still not clear exactly what you want. I can't guess my way to helping you, can't provide an answer if I don't know the question. Can you be exact and specific on exactly what you're trying to do?





For example, asking for an input of a value less than one and turning it into a time of hours, minutes, seconds. You mention that a value of one represents one year, but you said nothing about that in your original question. Are you saying that a value of one is exactly one year and a value between zero and one represents that fractional part of the year, and it needs to be transformed into days, hours, minutes, seconds, or months, weeks, days, hours, minutes, or something along those lines? Because I cannot tell if that is what you are looking for.


No comments:

Post a Comment