-
Notifications
You must be signed in to change notification settings - Fork 0
calendar.h ~ calendar ~ duration_type
Baptiste Thémine edited this page Jun 13, 2020
·
4 revisions
struct duration_type;
Defines structure to store human-readable duration representation.
The helper function calendar::make_duration permits to easily initialize a duration_type
structure by calculating default values for other members.
If one member is initialized with a value outside of its predefined range, the program is ill-formed and might result in undefined behaviour.
Name | Value | Description |
---|---|---|
year | integer from 0 to 292471208 | Year |
month | integer from 0 to 11 | Month in a year |
week | integer from 0 to 4 | Week in a month |
day | integer from 0 to 6 | Day in a week |
hour | integer from 0 to 23 | Hour |
min | integer from 0 to 59 | Minute |
sec | integer from 0 to 59 | Second |
milli | integer from 0 to 999 | Millisecond |
#include <iostream>
#include <JLC/JLC.h>
using namespace JLC;
using typename calendar::duration_type;
int main(){
constexpr duration_type duration = calendar::make_duration(0,0,123);
std::cout << "123 weeks = " << duration.year << " years";
std::cout << " + " << duration.month << " months";
std::cout << " + " << duration.week << " weeks";
std::cout << " + " << duration.day << " days" << std::endl;
}
123 weeks = 2 years + 4 months + 1 weeks + 0 days