# MTPCCycle

A cycle, as used by a discount, counter, or aggregate rate.

To view an object model diagram that includes MTPCCycle, click here.

## Program ID

Metratech.MTPCCycle.1

## MTPCCycle Methods

ComputeCycleIDFromProperties | Sets the CycleID from properties that are returned. (CycleTypeID is already set.) If Relative is true, then the CycleID is 0. Before saving MTPCCycle to database, the owning object should do the following: Call ComputeCycleIDFromProperties. Get CycleID and CycleTypeID and save it in the database.
ComputePropertiesFromCycleID | Sets all properties, depending on CycleID and CycleTypeID. If CycleID is 0, Relative will be set to true and all properties other than CycleTypeID to 0. If CycleID is != (not equal to) 0, Relative will be set to false and all properties other than CycleTypeID will be computed. When loading MTPCCycle from database the owning object should do the following: Set CycleID and CycleTypeID. Call ComputePropertiesFromCycleID.
CreateAbsoluteCycle | If this is a relative MTPCCycle, call this function to compute an absolute cycle based on this cycle's type and a given date (usually the effective date of a subscription).
GetTimeSpans | Given two points in time, this method computes how many intervals of this cycle occur between the two points (inclusive). Even if an interval is only partly contained between the two points, it is included.
GetTimeSpan | Given one point in time, this method computes the time span that encloses the point in time, based on the cycle.
CopyTo | This method copies this cycle to another one.

## Properties

Properties | Returns all (core and extended) properties of this object as a collection of MTProperty objects.
CycleID | The ID in t_usage_cycle. Use 0 for a relative cycle.
CycleTypeID | Specifies the usage cycle type: 3 = Daily 4 = Weekly 5 = Biweekly 6 = Semimonthly 1 = Monthly 7 = Quarterly
Relative | If true, only cycle type is used.
EndDayOfWeek | Specifies the day when a weekly cycle ends: 1 = Sunday 2 = Monday 3 = Tuesday 4 = Wednesday 5 = Thursday 6 = Friday 7 = Saturday
EndDayOfMonth | Specifies the day when a monthly cycle ends. For example, 15 indicates that the cycle ends on the 15th of every month. A value greater than 27 specifies that the cycle ends on the last day of the month.
EndDayOfMonth2 | Specifies the day when the second of a semimonthly cycle ends. A value greater than 27 specifies that the cycle ends on the last day of the month.
StartDay | Indicates an absolute (invariable) day of the month to start a monthly cycle.
StartMonth | Indicates the month when the cycle starts.
StartYear | Indicates the year when the cycle starts.
AdapterProgID | The adapter used for date calculations (based on the cycle type).
CycleTypeDescription | A short, English-only, text description of he cycle type in the database (for example, Weekly). This is set when a call to a Compute* method is made.

# Method Detail

## ComputeCycleIDFromProperties

specifies the CycleID from properties that are returned. (CycleTypeID is already set.)

If Relative is true, then the CycleID is 0.

Before saving MTPCCycle to database, the owning object must do the following:

- Call ComputeCycleIDFromProperties.

- Get CycleID and CycleTypeID and save it in DB.

### Visual Basic Syntax

ComputeCycleIDFromProperties ();

### C++ Syntax

HRESULT IMTPCCycle::ComputeCycleIDFromProperties();

## ComputePropertiesFromCycleID

Sets all properties, depending on CycleID and CycleTypeID.

If CycleID is 0, then Relative is set to true and all properties other than CycleTypeID to are set to 0.

If CycleID is != (not equal to) 0, Relative is set to false and all properties other than CycleTypeID are computed.

When loading MTPCCycle from database, the owning object must do the following:

- Set CycleID and CycleTypeID.

- Call ComputePropertiesFromCycleID.

### Visual Basic Syntax

ComputePropertiesFromCycleID ();

### C++ Syntax

HRESULT ComputePropertiesFromCycleID();

## CreateAbsoluteCycle

If this is a relative MTPCCycle, then call this function to compute an absolute cycle based on this cycle's type and a given date (usually the effective date of a subscription).

### Visual Basic Syntax

CreateAbsoluteCycle(aReference As Date) As MTPCCycle

### C++ Syntax

HRESULT CreateAbsoluteCycle([in] Date aReference, [out, retval] IMTPCCycle **;

## GetTimeSpans

Given two points in time, this method will compute how many intervals of this cycle occur between the two points (inclusive). Even if an interval is only partly contained between the two points, it is included.

### Visual Basic Syntax

GetTimeSpans(aStartDate As DATE)

### C++ Syntax

HRESULT GetTimeSpans([in] DATE aStartDate, [in] DATE aEndDate, [out, retval] IMTCollection** apColl);

## GetTimeSpan

Given one point in time, this method will compute the time span that encloses the point in time based on the cycle.

### Visual Basic Syntax

GetTimeSpan(Reference As DATE)

### C++ Syntax

HRESULT GetTimeSpan([in] DATE aReference, [out, retval] IMTPCTimeSpan** apTimeSpan);

## CopyTo

This method copies this cycle to another one.

### Visual Basic Syntax

CopyTo() As MTPCCycle**

### C++ Syntax

HRESULT CopyTo([out, retval] IMTPCCycle** apCopyTo);

# Property Detail

## Properties

This property returns all (core and extended) properties of this object as a collection of MTProperty objects.

### Visual Basic Syntax

Properties() As MTProperties

### C++ Syntax

HRESULT Properties([out, retval] IMTProperties * *pVal);

## CycleID

This property specifies the ID in t_usage_cycle.

Use 0 for a relative cycle.

### Visual Basic Syntax

Property CycleID As Long

### C++ Syntax

HRESULT CycleID([out, retval] long *pVal);

HRESULT CycleID([in] long newVal);

## CycleTypeID

This property specifies the usage cycle type:

3 = Daily

4 = Weekly

5 = Biweekly

6 = Semimonthly

1 = Monthly

7 = Quarterly

### Visual Basic Syntax

Property CycleTypeID As Long

### C++ Syntax

HRESULT CycleTypeID([out, retval] long *pVal);

HRESULT CycleTypeID([in] long newVal);

## Relative

If this boolean property is true, only cycle type is used.

### Visual Basic Syntax

Property Relative As Boolean Variant

### C++ Syntax

HRESULT Relative([out, retval] VARIANT_BOOL *pVal);

HRESULT Relative([in] VARIANT_BOOL newVal);

## EndDayOfWeek

This property specifies the day when weekly cycle ends:

1 = Sunday

2 = Monday

3 = Tuesday

4 = Wednesday

5 = Thursday

6 = Friday

7 = Saturday

### Visual Basic Syntax

Property EndDayOfWeek As Long

### C++ Syntax

HRESULT EndDayOfWeek([out, retval] long *pVal);

HRESULT EndDayOfWeek([in] long newVal);

## EndDayOfMonth

This property specifies the day when a monthly cycle ends. For example, 15 indicates that the cycle ends on the 15th of every month.

A value greater than 27 specifies that the cycle ends on the last day of the month.

### Visual Basic Syntax

Property EndDayOfMonth As Long

### C++ Syntax

HRESULT EndDayOfMonth([out, retval] long *pVal);

HRESULT EndDayOfMonth([in] long newVal);

## EndDayOfMonth2

This property specifies the day when the second of a semimonthly cycle ends.

A value greater than 27 specifies that the cycle ends on the last day of the month.

### Visual Basic Syntax

Property EndDayOfMonth2 As Long

### C++ Syntax

HRESULT EndDayOfMonth2([out, retval] long *pVal);

HRESULT EndDayOfMonth2([in] long newVal);

## StartDay

This property indicates an absolute (invariable) day of the month to start a monthly cycle.

### Visual Basic Syntax

Property StartDay As Long

### C++ Syntax

HRESULT StartDay([out, retval] long *pVal);

HRESULT StartDay([in] long newVal);

## StartMonth

This property indicates the month when the cycle starts.

### Visual Basic Syntax

Property StartMonth As Long

### C++ Syntax

HRESULT StartMonth([out, retval] long *pVal);

HRESULT StartMonth([in] long newVal);

## StartYear

This property indicates the year when the cycle starts.

### Visual Basic Syntax

Property StartYear As Long

### C++ Syntax

HRESULT StartYear([out, retval] long *pVal);

HRESULT StartYear([in] long newVal);

## AdapterProgID

This property specifies the adapter used for date calculations (based on the cycle type).

### Visual Basic Syntax

Property AdapterProgID As String

### C++ Syntax

HRESULT AdapterProgID([out, retval] BSTR *pVal);

## CycleTypeDescription

This property is a short, English-only, text description of the cycle type in the database (for example, Weekly). This is set when a call to a Compute* method is made.

### Visual Basic Syntax

Property CycleTypeDescription As String

### C++ Syntax

HRESULT CycleTypeDescription([out, retval] BSTR *pVal);