BloombergLP::bdlt::Datetime::setDatetimeIfValid

Set this object from calendar fields if they form a valid datetime.

Synopsis

Declared in <bdlt_datetime.h>

int
setDatetimeIfValid(
    int year,
    int month,
    int day,
    int hour = 0,
    int minute = 0,
    int second = 0,
    int millisecond = 0,
    int microsecond = 0);

Description

Set the "date" part of this object to have the value represented by the specified year, month, and day attributes, and set the "time" part to have the value represented by the optionally specified hour, minute, second, millisecond, and microsecond attributes, if the eight attribute values (collectively) represent a valid Datetime value (see isValid). Unspecified trailing optional parameters default to 0. Return 0 on success, and a non-zero value (with no effect) otherwise.

Return Value

0 on success, and a non-zero value otherwise

Parameters

NameDescription
yearyear attribute
monthmonth attribute
dayday-of-month attribute
hourhour attribute (default 0)
minuteminute attribute (default 0)
secondsecond attribute (default 0)
millisecondmillisecond attribute (default 0)
microsecondmicrosecond attribute (default 0)