Quick Links: |
#include <bdlt_posixdateimputil.h>
Classes | |
struct | YearMonthDay |
Static Public Member Functions | |
static bool | isLeapYear (int year) |
static int | lastDayOfMonth (int year, int month) |
static int | numLeapYears (int year1, int year2) |
static bool | isValidYearMonthDay (int year, int month, int day) |
static bool | isValidYearMonthDayNoCache (int year, int month, int day) |
static bool | isValidSerial (int serialDay) |
static bool | isValidYearDay (int year, int dayOfYear) |
static int | ydToSerial (int year, int dayOfYear) |
static int | ymdToSerial (int year, int month, int day) |
static int | ymdToSerialNoCache (int year, int month, int day) |
static int | serialToDayOfYear (int serialDay) |
static void | serialToYd (int *year, int *dayOfYear, int serialDay) |
static int | ymdToDayOfYear (int year, int month, int day) |
static int | serialToDay (int serialDay) |
static int | serialToDayNoCache (int serialDay) |
static int | serialToMonth (int serialDay) |
static int | serialToMonthNoCache (int serialDay) |
static int | serialToYear (int serialDay) |
static int | serialToYearNoCache (int serialDay) |
static void | serialToYmd (int *year, int *month, int *day, int serialDay) |
static void | serialToYmdNoCache (int *year, int *month, int *day, int serialDay) |
static int | ydToDay (int year, int dayOfYear) |
static void | ydToMd (int *month, int *day, int year, int dayOfYear) |
static int | ydToMonth (int year, int dayOfYear) |
static int | serialToDayOfWeek (int serialDay) |
static int | ydToDayOfWeek (int year, int dayOfYear) |
static int | ymdToDayOfWeek (int year, int month, int day) |
This struct
provides a namespace for a suite of pure functions that perform low-level operations on date values in a variety of formats. Note that all of these functions, whether or not implemented in terms of a static cache, are stateless, and, as such, are inherently thread-safe.
See Component bdlt_posixdateimputil
static bool bdlt::PosixDateImpUtil::isLeapYear | ( | int | year | ) | [static] |
Return true
if the specified year
is a leap year, and false
otherwise. The behavior is undefined unless 1 <= year <= 9999
.
static int bdlt::PosixDateImpUtil::lastDayOfMonth | ( | int | year, | |
int | month | |||
) | [static] |
Return the last day of the specified month
in the specified year
. The behavior is undefined unless 1 <= year <= 9999
and 1 <= month <= 12
. Note that the value returned will be in the range [ 28 .. 31 ]
.
static int bdlt::PosixDateImpUtil::numLeapYears | ( | int | year1, | |
int | year2 | |||
) | [static] |
Return the number of leap years occurring between the specified year1
and year2
(inclusive). The behavior is undefined unless 1 <= year1 <= 9999
, 1 <= year2 <= 9999
, and year1 <= year2
.
static bool bdlt::PosixDateImpUtil::isValidYearMonthDay | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
Return true
if the specified year
, month
, and day
represents a valid date value, and false
otherwise. Note that valid date values are (as fully defined in the component-level documentation) in the range [ 0001/01/01 .. 9999/12/31 ]
(except that [ 1752/09/03 .. 1752/09/13 ]
are not valid for historical reasons).
static bool bdlt::PosixDateImpUtil::isValidYearMonthDayNoCache | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
Return true
if the specified year
, month
, and day
represents a valid date value, and false
otherwise. Note that valid date values are (as fully defined in the component-level documentation) in the range [ 0001/01/01 .. 9999/12/31 ]
(except that [ 1752/09/03 .. 1752/09/13 ]
are not valid for historical reasons). Also note that this function is guaranteed not to use any date-cache optimizations.
static bool bdlt::PosixDateImpUtil::isValidSerial | ( | int | serialDay | ) | [static] |
Return true
if the specified serialDay
represents a valid date value, and false
otherwise. Note that valid date values are (as fully defined in the component-level documentation) in the range [ 1 .. 3652061 ]
.
static bool bdlt::PosixDateImpUtil::isValidYearDay | ( | int | year, | |
int | dayOfYear | |||
) | [static] |
Return true
if the specified year
and dayOfYear
represents a valid date value, and false
otherwise. Note that valid date values are (as fully defined in the component-level documentation) in the range [ 0001/01 .. 9999/365 ]
(except that [ 1752/356 .. 1752/366 ]
are not valid for historical reasons).
static int bdlt::PosixDateImpUtil::ydToSerial | ( | int | year, | |
int | dayOfYear | |||
) | [static] |
Return the serial date representation of the date value indicated by the specified year
and dayOfYear
. The behavior is undefined unless true == isValidYearDay(year, dayOfYear)
.
static int bdlt::PosixDateImpUtil::ymdToSerial | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
Return the serial date representation of the date value indicated by the specified year
, month
, and day
. The behavior is undefined unless true == isValidYearMonthDay(year, month, day)
.
static int bdlt::PosixDateImpUtil::ymdToSerialNoCache | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
Return the serial date representation of the date value indicated by the specified year
, month
, and day
. The behavior is undefined unless true == isValidYearMonthDay(year, month, day)
. Note that this function is guaranteed not to use any date-cache optimizations.
static int bdlt::PosixDateImpUtil::serialToDayOfYear | ( | int | serialDay | ) | [static] |
Return the day of the year of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static void bdlt::PosixDateImpUtil::serialToYd | ( | int * | year, | |
int * | dayOfYear, | |||
int | serialDay | |||
) | [static] |
Load, into the specified year
and dayOfYear
, the year-day representation of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static int bdlt::PosixDateImpUtil::ymdToDayOfYear | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
Return the day of the year of the date value indicated by the specified year
, month
, and day
. The behavior is undefined unless true == isValidYearMonthDay(year, month, day)
.
static int bdlt::PosixDateImpUtil::serialToDay | ( | int | serialDay | ) | [static] |
Return the day (of the month) of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static int bdlt::PosixDateImpUtil::serialToDayNoCache | ( | int | serialDay | ) | [static] |
Return the day (of the month) of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
. Note that this function is guaranteed not to use any date-cache optimizations.
static int bdlt::PosixDateImpUtil::serialToMonth | ( | int | serialDay | ) | [static] |
Return the month of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static int bdlt::PosixDateImpUtil::serialToMonthNoCache | ( | int | serialDay | ) | [static] |
Return the month of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
. Note that this function is guaranteed not to use any date-cache optimizations.
static int bdlt::PosixDateImpUtil::serialToYear | ( | int | serialDay | ) | [static] |
Return the year of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static int bdlt::PosixDateImpUtil::serialToYearNoCache | ( | int | serialDay | ) | [static] |
Return the year of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
. Note that this function is guaranteed not to use any date-cache optimizations.
static void bdlt::PosixDateImpUtil::serialToYmd | ( | int * | year, | |
int * | month, | |||
int * | day, | |||
int | serialDay | |||
) | [static] |
Load, into the specified year
, month
, and day
, the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static void bdlt::PosixDateImpUtil::serialToYmdNoCache | ( | int * | year, | |
int * | month, | |||
int * | day, | |||
int | serialDay | |||
) | [static] |
Load, into the specified year
, month
, and day
, the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
. Note that this function is guaranteed not to use any date-cache-optimizations.
static int bdlt::PosixDateImpUtil::ydToDay | ( | int | year, | |
int | dayOfYear | |||
) | [static] |
Return the day (of the month) of the date value indicated by the specified year
and dayOfYear
. The behavior is undefined unless true == isValidYearDay(year, dayOfYear)
.
static void bdlt::PosixDateImpUtil::ydToMd | ( | int * | month, | |
int * | day, | |||
int | year, | |||
int | dayOfYear | |||
) | [static] |
Load, into the specified month
and day
, the (partial) calendar date representation of the date value indicated by the specified year
and dayOfYear
. The behavior is undefined unless true == isValidYearDay(year, dayOfYear)
.
static int bdlt::PosixDateImpUtil::ydToMonth | ( | int | year, | |
int | dayOfYear | |||
) | [static] |
Return the month of the date value indicated by the specified year
and dayOfYear
. The behavior is undefined unless true == isValidYearDay(year, dayOfYear)
.
static int bdlt::PosixDateImpUtil::serialToDayOfWeek | ( | int | serialDay | ) | [static] |
Return, as an integer (with 1 = SUN
, 2 = MON
, ..., and 7 = SAT
), the day (of the week) of the date value indicated by the specified serialDay
. The behavior is undefined unless true == isValidSerial(serialDay)
.
static int bdlt::PosixDateImpUtil::ydToDayOfWeek | ( | int | year, | |
int | dayOfYear | |||
) | [static] |
Return, as an integer (with 1 = SUN
, 2 = MON
, ..., and 7 = SAT
), the day (of the week) of the date value indicated by the specified year
and dayOfYear
. The behavior is undefined unless true == isValidYearDay(year, dayOfYear)
.
static int bdlt::PosixDateImpUtil::ymdToDayOfWeek | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
Return, as an integer (with 1 = SUN
, 2 = MON
, ..., and 7 = SAT
), the day (of the week) of the date value indicated by the specified year
, month
, and day
. The behavior is undefined unless true == isValidYearMonthDay(year, month, day)
.