Subtracting Waiting Time from Current Time (24-Hour Notation)

This is a discussion on Subtracting Waiting Time from Current Time (24-Hour Notation) within the C++ Programming forums, part of the General Programming Boards category; Okay, so I have created a program that allows a user to convert 24-hour notation to 12-hour notation. Ex// it ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    14

    Subtracting Waiting Time from Current Time (24-Hour Notation)

    Okay, so I have created a program that allows a user to convert 24-hour notation to 12-hour notation. Ex// it converts 14:25 to 2:25 PM. Though now I'm having trouble subtracting a waiting period from the current time, and then output what the time will be after the waiting period.

    If you need the conversion code from 24hrN to 12hrN let me know.

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    14
    I know that the waiting time, and the current time need to be two seperate intergers. I just need some kind of idea on how to start this off. Thanks again for all your help.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    If you can convert between minutes and hr:mm, then it's easy.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    May 2007
    Posts
    14
    still having a bit problem with this one.. maybe im overthinking it ??

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,499
    When you read a time, convert it to minutes (hh*60+mm)

    When you output a time, convert it to hh:mm

    Any calculations in the meantime are done just on minutes.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    2
    can you show me the coding?

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    2
    Quote Originally Posted by impact View Post
    Okay, so I have created a program that allows a user to convert 24-hour notation to 12-hour notation. Ex// it converts 14:25 to 2:25 PM. Though now I'm having trouble subtracting a waiting period from the current time, and then output what the time will be after the waiting period.

    If you need the conversion code from 24hrN to 12hrN let me know.
    help needed please...

  8. #8
    Registered User
    Join Date
    Aug 2005
    Posts
    266
    store time as h:m:s
    store waiting time as h:m:s

    create method to change h:m:s -> s
    create method to change s ->h:m:s

    use methods to do the following:
    change currentTime -> s
    change waitingTime ->s

    (currentTime + waiting time)s -> h:m:s

    .

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. inputting time in separate compilation
    By sameintheend01 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2003, 03:33 AM
  2. current time
    By lithium in forum C Programming
    Replies: 3
    Last Post: 01-26-2003, 04:42 PM
  3. current time
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 05-21-2002, 09:48 AM
  4. I apologize. Good bye.
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 05-03-2002, 06:51 PM
  5. Adding and subtracting time?
    By JCCC in forum C Programming
    Replies: 3
    Last Post: 03-29-2002, 01:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21