Thread: Military Time Functions

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You could replace that with:

    endingtime %= 2400;
    If you understand what you're doing, you're not learning anything.

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    I have been waiting to see if anyone really knows what military time is. I personally feel that it's important to understand the problem before you start writing code.

    It isn't an integer that starts at 0000 and goes to ????

    Military time expresses hours from 00 to 23 and minutes from 00 to 59, and writes them together so that it looks like a 4-digit integer.

    For example suppose the present time is 12:45 pm in "human" time.

    In military time that's 1245, OK?

    Now suppose the duration is two hours and 30 minutes.

    What's the ending time? That is, what integer do you add to 1245 to get the ending time?

    Work another problem: suppose the starting time is 12:45 pm (1245 in military time). Suppose the ending time is 4:05 pm (same day). That's 1605 military. What's the duration? You can't just subtract 1245 from 1605. (Well you could, but you'd get the wrong answer.)

    Minutes: modulo 60
    Hours : modulo 24.



    As far as "proper expression", the following is a syntactically correct expression for calculating something, but does not give the correct answer for all possible input values. Whether it is "proper" or not, it doesn't solve the problem that was stated.

    Saying something is "not proper" sounds like an etiquette lesson. I would have said "wrong".

    Code:
    endingtime=startingtime+durationtime-60+100;
    Regards,

    Dave
    Last edited by Dave Evans; 10-10-2004 at 04:13 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help in time zone
    By Gong in forum C++ Programming
    Replies: 2
    Last Post: 01-03-2007, 04:44 AM
  2. Help with assignment!
    By RVDFan85 in forum C++ Programming
    Replies: 12
    Last Post: 12-03-2006, 12:46 AM
  3. Elevator Function confusion
    By applescruff in forum C++ Programming
    Replies: 5
    Last Post: 12-16-2004, 10:14 AM
  4. The space time continueimnms mm... (rant)
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 06-27-2004, 01:21 PM
  5. I apologize. Good bye.
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-03-2002, 06:51 PM