Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:08:50+00:00 2026-06-10T11:08:50+00:00

Here is a implementation that I wrote to add hrs, min and sec in

  • 0

Here is a implementation that I wrote to add hrs, min and sec in C++
Is there a way to implement this by converting all this to seconds and do a simpler implementation?
For some reason it wouldn’t let me add the code in this post 🙁

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:08:52+00:00Added an answer on June 10, 2026 at 11:08 am

    Is there a way to implement this by converting all this to seconds and do a simpler implementation?

    Whichever way you go, you’ll need to change the time between seconds and hour/minute/second quite often, so there’s not necessarily a huge benefit to using one or the other for storage. Put another way, seconds-since-midnight is probably nicer, but maybe not worth a rewrite. For things like + and -, if you’re not storing just seconds then you can calculate it easily (see Mark’s post), do your arithmetic then have a function to convert from seconds back to hour/min/sec to store the result into your data members:

    hours = seconds_since_midnight / 60 / 60;
    minutes = seconds_since_midnight / 60 % 60;
    seconds = seconds_since_midnight % 60;
    

    Say you’re adding 120 seconds to 23:59:00, you’ll get a value past midnight, so you can use “total_seconds % 24 * 60 * 60” to get just the 60 seconds past the following midnight, equivalent to wrapping from “24:01:00” to 00:01:00.

    (If you want to actually use this, and not just doing this to teach yourself, then consider using the time() function and associated conversion routines like localtime())

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a question that comes up again and again in C++ class implementation. I'm
Here is my implementation in summary 1) all DAOs implemented using HibernateDAO support/ @Transational
Here's the implementation of java.lang.reflect.Method.equals(Object obj) as of Java 7: /** * Compares this
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
here's a little code I wrote. This next class waits for a connection and
I wrote a UnitOfWork implementation that does not expose a public Commit() method. Instead
I'm having some difficulties getting the TabActivity to work. Here's the implementation of the
Here is the code : @implementation Accumulateur // Constructor - (id) init { return
Here is the hashCode() implementation from Java HashTable Class. What if the number of
Here is my perceptron implementation in ANSI C: #include <stdio.h> #include <stdlib.h> #include <math.h>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.