# Cloud Optimization v1 API - Class TimeWindow (2.7.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.7.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.TimeWindow)
- [2.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.6.0/Google.Cloud.Optimization.V1.TimeWindow)
- [2.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.5.0/Google.Cloud.Optimization.V1.TimeWindow)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.4.0/Google.Cloud.Optimization.V1.TimeWindow)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.3.0/Google.Cloud.Optimization.V1.TimeWindow)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.2.0/Google.Cloud.Optimization.V1.TimeWindow)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.1.0/Google.Cloud.Optimization.V1.TimeWindow)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.0.0/Google.Cloud.Optimization.V1.TimeWindow)
- [1.0.0-beta01](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/1.0.0-beta01/Google.Cloud.Optimization.V1.TimeWindow)

    public sealed class TimeWindow : IMessage<TimeWindow>, IEquatable<TimeWindow>, IDeepCloneable<TimeWindow>, IBufferMessage, IMessage

Reference documentation and code samples for the Cloud Optimization v1 API class TimeWindow.

Time windows constrain the time of an event, such as the arrival time at a
visit, or the start and end time of a vehicle.

Hard time window bounds, `start_time` and `end_time`, enforce the earliest
and latest time of the event, such that `start_time <= event_time <=
end_time`. The soft time window lower bound, `soft_start_time`, expresses a
preference for the event to happen at or after `soft_start_time` by incurring
a cost proportional to how long before soft_start_time the event occurs. The
soft time window upper bound, `soft_end_time`, expresses a preference for the
event to happen at or before `soft_end_time` by incurring a cost proportional
to how long after `soft_end_time` the event occurs. `start_time`, `end_time`,
`soft_start_time` and `soft_end_time` should be within the global time limits
(see
\[ShipmentModel.global_start_time\]\[google.cloud.optimization.v1.ShipmentModel.global_start_time\]
and
\[ShipmentModel.global_end_time\]\[google.cloud.optimization.v1.ShipmentModel.global_end_time\])
and should respect:

      0 <= `start_time` <= `soft_start_time` <= `end_time` and
      0 <= `start_time` <= `soft_end_time` <= `end_time`.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> TimeWindow

## Implements

[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[TimeWindow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.TimeWindow), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[TimeWindow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.TimeWindow), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[TimeWindow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.TimeWindow), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html)

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Optimization.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1)

## Assembly

Google.Cloud.Optimization.V1.dll

## Constructors

### TimeWindow()

    public TimeWindow()

### TimeWindow(TimeWindow)

    public TimeWindow(TimeWindow other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.TimeWindow` |

## Properties

### CostPerHourAfterSoftEndTime

    public double CostPerHourAfterSoftEndTime { get; set; }

A cost per hour added to other costs in the model if the event occurs after
`soft_end_time`, computed as:

       max(0, t.seconds - soft_end_time.seconds)
                        * cost_per_hour_after_soft_end_time / 3600,
    t being the time of the event.

This cost must be positive, and the field can only be set if
`soft_end_time` has been set.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.double` |   |

### CostPerHourBeforeSoftStartTime

    public double CostPerHourBeforeSoftStartTime { get; set; }

A cost per hour added to other costs in the model if the event occurs
before soft_start_time, computed as:

       max(0, soft_start_time - t.seconds)
                              * cost_per_hour_before_soft_start_time / 3600,
    t being the time of the event.

This cost must be positive, and the field can only be set if
soft_start_time has been set.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.double` |   |

### EndTime

    public Timestamp EndTime { get; set; }

The hard time window end time. If unspecified it will be set to
`ShipmentModel.global_end_time`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` |   |

### HasCostPerHourAfterSoftEndTime

    public bool HasCostPerHourAfterSoftEndTime { get; }

Gets whether the "cost_per_hour_after_soft_end_time" field is set

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### HasCostPerHourBeforeSoftStartTime

    public bool HasCostPerHourBeforeSoftStartTime { get; }

Gets whether the "cost_per_hour_before_soft_start_time" field is set

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### SoftEndTime

    public Timestamp SoftEndTime { get; set; }

The soft end time of the time window.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` |   |

### SoftStartTime

    public Timestamp SoftStartTime { get; set; }

The soft start time of the time window.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` |   |

### StartTime

    public Timestamp StartTime { get; set; }

The hard time window start time. If unspecified it will be set to
`ShipmentModel.global_start_time`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Timestamp.html` |   |