I am required to store a time value in an integer in the format of HHMMSS. this time value is incrementing every second (basically a custom clock). however, since integers are naturally 10 based, I must implement a large cumbersome logic that extracts each digits and checks for 60 seconds in a minutes, 60 minutes in an hour and 24 hours a day. I wonder if there is some clever ways to do it without a massive if/else if chunk.
I am required to store a time value in an integer in the format
Share
You can use the modulus operator to pick out each of the components of a single seconds counter:
Then you can just increment a single seconds counter and extract each of the components.