Skip to content

calendar.h ~ calendar ~ make_datetime

Baptiste Thémine edited this page Aug 6, 2020 · 9 revisions
constexpr datetime_type make_datetime(int year=1, int month=1, int day=1, int hour=0, int min=0, int sec=0, int milli=0, int utctz=0) noexcept;

Description

Initializes a valid ISO 8601 datetime_type structure.

Parameters

(Optional)

  • year --> Year from 1 to 292277025
  • month --> Month from 1 to 12
  • day --> Day of month from 1 to 31
  • hour --> Hour from 0 to 23
  • min --> Minute from 0 to 59
  • sec --> Second from 0 to 59
  • milli --> Millisecond from 0 to 999
  • utctz --> UTC time zone offset from -1800 to +1800

Return value

If the specified parameters represent a valid ISO 8601 date, returns a valid datetime_type object with all its members initialized, otherwise returns a default initialized datetime_type.

Exceptions

Never throws exception.

Examples

#include <iostream>
#include <JLC/JLC.h>
using namespace JLC;
using typename calendar::datetime_type;

int main(){
    constexpr datetime_type datetime = calendar::make_datetime(2012,12,12);
    std::cout << "Day of year = " << datetime.yday << std::endl;
    std::cout << "Week of year = " << datetime.yweek << std::endl;
}
Day of year = 347
Week of year = 50

See also

Clone this wiki locally