BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlt_dayofweekutil

Detailed Description

Provide common non-primitive operations on bdlt::DayOfWeek::Enum.

Outline

Purpose

Provide common non-primitive operations on bdlt::DayOfWeek::Enum.

Classes

See also
bdlt_dayofweek

Description

This utility component provides a struct, bdlt::DayOfWeekUtil, that serves as a namespace for functions operating on the day-of-week enumeration.

This component provides the following (static) methods:

'add' Determine the day of the week that results from
shifting a given 'bdlt::DayOfWeek::Enum' value
by a given (signed) number of days.

Usage

This section illustrates intended use of this component.

Example 1: Basic Usage

Suppose we have some event occurring every ten days. Today is the day of the performance, assumed to be a Friday, and we want to know when the previous one took place and when the next one will be.

First, we create a bdlt::DayOfWeek variable for the current day:

Enum
Enumerated day-of-week values.
Definition bdlt_dayofweek.h:125
@ e_FRI
Definition bdlt_dayofweek.h:132

Next, we calculate previous and following event days using the bdlt::DayOfWeekUtil::add function:

static BSLS_CPP11_CONSTEXPR DayOfWeek::Enum add(DayOfWeek::Enum dayOfWeek, int numDays)
Definition bdlt_dayofweekutil.h:142

Finally, we verify the resultant day-of-week values:

assert(bdlt::DayOfWeek::e_TUE == previous );
assert(bdlt::DayOfWeek::e_MON == following);
@ e_TUE
Definition bdlt_dayofweek.h:129
@ e_MON
Definition bdlt_dayofweek.h:128