NBera
NBera

Reputation: 379

Representing Time in C++

im creating a constructor to set the default time to midnight. My question is how would you represent time as an int because i have other functions that add minutes,hours,etc to it.

Datatype IsMidnight;

DataType SetToMidnight( datatype M){

//set the default time to midnight not sure how to represent midnight as HH:MM
// example datatype= 12:00; 

}

Upvotes: 1

Views: 984

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172418

You are probably looking for C++11's, std::chrono

The chrono library defines three main types (durations, clocks, and time points) as well as utility functions and common typedefs.

You can also look for Boost which has a Date/Time library.

Upvotes: 1

Related Questions